Compare commits

3 Commits

Author SHA1 Message Date
cb381faa1e drm: verisilicon: fix fbcon
Always map the GEM object, because it may expect different page
attributes than the fixed map by kernel.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
2026-04-17 16:47:11 +08:00
Han Gao
8b46a2314b drm: img: add zhihe a210 build
Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
2026-04-17 16:47:11 +08:00
Han Gao
ecf5e527ca a210: gpu: Add driver for PowerVR Rogue GPU
Add the driver for PowerVR Rogue graphics hardware.

Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
2026-04-17 16:47:11 +08:00
470 changed files with 259737 additions and 2 deletions

View File

@@ -389,6 +389,8 @@ source "drivers/gpu/drm/sprd/Kconfig"
source "drivers/gpu/drm/verisilicon/Kconfig"
source "drivers/gpu/drm/img-rogue/Kconfig"
config DRM_HYPERV
tristate "DRM Support for Hyper-V synthetic video device"
depends on DRM && PCI && MMU && HYPERV

View File

@@ -184,6 +184,7 @@ obj-y += hisilicon/
obj-y += mxsfb/
obj-y += tiny/
obj-$(CONFIG_DRM_PL111) += pl111/
obj-$(CONFIG_DRM_POWERVR_ROGUE) += img-rogue/
obj-$(CONFIG_DRM_TVE200) += tve200/
obj-$(CONFIG_DRM_XEN) += xen/
obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/

View File

@@ -0,0 +1,24 @@
config DRM_POWERVR_ROGUE
tristate "PowerVR Rogue"
depends on HAS_IOMEM
depends on DRM
select DRM_KMS_HELPER
select PM_DEVFREQ
select DEVFREQ_GOV_SIMPLE_ONDEMAND
select PM_OPP
select DEVFREQ_THERMAL
select SYNC_FILE
help
Driver for PowerVR Rogue graphics hardware.
Say Y here if your SoC contains a PowerVR Rogue GPU. For more
information, see <http://www.imgtec.com/powervr/>.
config DRM_POWERVR_ROGUE_DEBUG
bool "Enable PowerVR Rogue debug features"
depends on DRM_POWERVR_ROGUE
default n
help
Add additional debug features to the PowerVR Rogue driver.
To build a matching userspace, enable the following build options:
BUILD=debug SUPPORT_PAGE_FAULT_DEBUG=1 PVRSRV_ENABLE_GPU_MEMORY_INFO=1

View File

@@ -0,0 +1,14 @@
img_basedir := $(srctree)/$(src)
include $(img_basedir)/config_kernel.mk
obj-$(CONFIG_DRM_POWERVR_ROGUE) += pvrsrvkm.o
ccflags-y += \
-include config_kernel.h \
-I$(img_basedir)/include/drm \
-I$(img_basedir) \
-I$(img_basedir)/include \
-I$(img_basedir)/km \
-D__linux__
include $(img_basedir)/pvrsrvkm.mk

View File

@@ -0,0 +1,377 @@
/*************************************************************************/ /*!
@File
@Title Host memory management implementation for Linux
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mm.h>
#include <linux/string.h>
#include "img_defs.h"
#include "allocmem.h"
#include "pvr_debug.h"
#include "process_stats.h"
#include "osfunc.h"
/*
* When memory statistics are disabled, memory records are used instead.
* In order for these to work, the PID of the process that requested the
* allocation needs to be stored at the end of the kmalloc'd memory, making
* sure 4 extra bytes are allocated to fit the PID.
*
* There is no need for this extra allocation when memory statistics are
* enabled, since all allocations are tracked in DebugFS mem_area files.
*/
#if defined(PVRSRV_ENABLE_PROCESS_STATS) && !defined(PVRSRV_ENABLE_MEMORY_STATS)
/* kmalloc guarantees a minimal alignment which is ARCH_KMALLOC_MINALIGN. This
* alignment is architecture specific and can be quite big, e.g. on Aarch64
* it can be 64 bytes. This is too much for keeping a single PID field and could
* lead to a lot of wasted memory. This is a reason why we're defaulting to 8
* bytes alignment which should be enough for any architecture.
*/
#define ALLOCMEM_PID_SIZE_PADDING PVR_ALIGN(sizeof(IMG_UINT32), 8)
#else
#define ALLOCMEM_PID_SIZE_PADDING 0UL
#endif
/* How many times kmalloc can fail before the allocation threshold is reduced */
static const IMG_UINT32 g_ui32kmallocFailLimit = 10;
/* How many kmalloc failures happened since the last allocation threshold change */
static IMG_UINT32 g_ui32kmallocFailCount = 0;
/* Current kmalloc threshold value in bytes */
static IMG_UINT32 g_ui32kmallocThreshold = PVR_LINUX_KMALLOC_ALLOCATION_THRESHOLD;
/* Spinlock used so that the global variables above may not be modified by more than 1 thread at a time */
static DEFINE_SPINLOCK(kmalloc_lock);
static inline void OSTryDecreaseKmallocThreshold(void)
{
unsigned long flags;
spin_lock_irqsave(&kmalloc_lock, flags);
g_ui32kmallocFailCount++;
if (g_ui32kmallocFailCount >= g_ui32kmallocFailLimit)
{
g_ui32kmallocFailCount = 0;
if (g_ui32kmallocThreshold > PAGE_SIZE)
{
g_ui32kmallocThreshold >>= 1;
printk(KERN_INFO "Threshold is now set to %d\n", g_ui32kmallocThreshold);
}
}
spin_unlock_irqrestore(&kmalloc_lock, flags);
}
static inline void OSResetKmallocFailCount(void)
{
unsigned long flags;
spin_lock_irqsave(&kmalloc_lock, flags);
g_ui32kmallocFailCount = 0;
spin_unlock_irqrestore(&kmalloc_lock, flags);
}
static inline void _pvr_vfree(const void* pvAddr)
{
#if defined(DEBUG)
/* Size harder to come by for vmalloc and since vmalloc allocates
* a whole number of pages, poison the minimum size known to have
* been allocated.
*/
OSCachedMemSet((void*)pvAddr, PVRSRV_POISON_ON_ALLOC_VALUE,
PAGE_SIZE);
#endif
vfree(pvAddr);
}
static inline void _pvr_kfree(const void* pvAddr)
{
#if defined(DEBUG)
/* Poison whole memory block */
OSCachedMemSet((void*)pvAddr, PVRSRV_POISON_ON_ALLOC_VALUE,
ksize(pvAddr));
#endif
kfree(pvAddr);
}
static inline void *_pvr_alloc_stats_add(void *pvAddr, IMG_UINT32 ui32Size DEBUG_MEMSTATS_PARAMS)
{
#if !defined(PVRSRV_ENABLE_PROCESS_STATS)
PVR_UNREFERENCED_PARAMETER(pvAddr);
#else
if (!is_vmalloc_addr(pvAddr))
{
#if defined(PVRSRV_ENABLE_MEMORY_STATS)
IMG_CPU_PHYADDR sCpuPAddr;
sCpuPAddr.uiAddr = 0;
PVRSRVStatsAddMemAllocRecord(PVRSRV_MEM_ALLOC_TYPE_KMALLOC,
pvAddr,
sCpuPAddr,
ksize(pvAddr),
OSGetCurrentClientProcessIDKM()
DEBUG_MEMSTATS_ARGS);
#else
/* because clang has some features that allow detection out-of-bounds
* access we need to put the metadata in the beginning of the allocation */
*(IMG_UINT32 *) pvAddr = OSGetCurrentClientProcessIDKM();
PVRSRVStatsIncrMemAllocStat(PVRSRV_MEM_ALLOC_TYPE_KMALLOC, ksize(pvAddr),
*(IMG_UINT32 *) pvAddr);
/* because metadata is kept in the beginning of the allocation we need
* to return address offset by the ALLOCMEM_PID_SIZE_PADDING */
pvAddr = (IMG_UINT8 *) pvAddr + ALLOCMEM_PID_SIZE_PADDING;
#endif /* defined(PVRSRV_ENABLE_MEMORY_STATS) */
}
else
{
#if defined(PVRSRV_ENABLE_MEMORY_STATS)
IMG_CPU_PHYADDR sCpuPAddr;
sCpuPAddr.uiAddr = 0;
PVRSRVStatsAddMemAllocRecord(PVRSRV_MEM_ALLOC_TYPE_VMALLOC,
pvAddr,
sCpuPAddr,
PVR_ALIGN(ui32Size, PAGE_SIZE),
OSGetCurrentClientProcessIDKM()
DEBUG_MEMSTATS_ARGS);
#else
PVRSRVStatsIncrMemAllocStatAndTrack(PVRSRV_MEM_ALLOC_TYPE_VMALLOC,
PVR_ALIGN(ui32Size, PAGE_SIZE),
(IMG_UINT64)(uintptr_t) pvAddr,
OSGetCurrentClientProcessIDKM());
#endif /* defined(PVRSRV_ENABLE_MEMORY_STATS) */
}
#endif /* !defined(PVRSRV_ENABLE_PROCESS_STATS) */
return pvAddr;
}
static inline void *_pvr_alloc_stats_remove(void *pvAddr)
{
#if !defined(PVRSRV_ENABLE_PROCESS_STATS)
PVR_UNREFERENCED_PARAMETER(pvAddr);
#else
if (!is_vmalloc_addr(pvAddr))
{
#if !defined(PVRSRV_ENABLE_MEMORY_STATS)
/* because metadata is kept in the beginning of the allocation we need
* shift address offset by the ALLOCMEM_PID_SIZE_PADDING to the original
* value */
pvAddr = (IMG_UINT8 *) pvAddr - ALLOCMEM_PID_SIZE_PADDING;
/* first 4 bytes of the allocation are the process' PID */
PVRSRVStatsDecrMemKAllocStat(ksize(pvAddr), *(IMG_UINT32 *) pvAddr);
#else
PVRSRVStatsRemoveMemAllocRecord(PVRSRV_MEM_ALLOC_TYPE_KMALLOC,
(IMG_UINT64)(uintptr_t) pvAddr,
OSGetCurrentClientProcessIDKM());
#endif
}
else
{
#if !defined(PVRSRV_ENABLE_MEMORY_STATS)
PVRSRVStatsDecrMemAllocStatAndUntrack(PVRSRV_MEM_ALLOC_TYPE_VMALLOC,
(IMG_UINT64)(uintptr_t) pvAddr);
#else
PVRSRVStatsRemoveMemAllocRecord(PVRSRV_MEM_ALLOC_TYPE_VMALLOC,
(IMG_UINT64)(uintptr_t) pvAddr,
OSGetCurrentClientProcessIDKM());
#endif
}
#endif /* !defined(PVRSRV_ENABLE_PROCESS_STATS) */
return pvAddr;
}
void *(OSAllocMem)(IMG_UINT32 ui32Size DEBUG_MEMSTATS_PARAMS)
{
void *pvRet = NULL;
if ((ui32Size + ALLOCMEM_PID_SIZE_PADDING) <= g_ui32kmallocThreshold)
{
pvRet = kmalloc(ui32Size + ALLOCMEM_PID_SIZE_PADDING, GFP_KERNEL);
if (pvRet == NULL)
{
OSTryDecreaseKmallocThreshold();
}
else
{
OSResetKmallocFailCount();
}
}
if (pvRet == NULL)
{
pvRet = vmalloc(ui32Size);
}
if (pvRet != NULL)
{
pvRet = _pvr_alloc_stats_add(pvRet, ui32Size DEBUG_MEMSTATS_ARGS);
}
return pvRet;
}
void *(OSAllocZMem)(IMG_UINT32 ui32Size DEBUG_MEMSTATS_PARAMS)
{
void *pvRet = NULL;
if ((ui32Size + ALLOCMEM_PID_SIZE_PADDING) <= g_ui32kmallocThreshold)
{
pvRet = kzalloc(ui32Size + ALLOCMEM_PID_SIZE_PADDING, GFP_KERNEL);
if (pvRet == NULL)
{
OSTryDecreaseKmallocThreshold();
}
else
{
OSResetKmallocFailCount();
}
}
if (pvRet == NULL)
{
pvRet = vzalloc(ui32Size);
}
if (pvRet != NULL)
{
pvRet = _pvr_alloc_stats_add(pvRet, ui32Size DEBUG_MEMSTATS_ARGS);
}
return pvRet;
}
/*
* The parentheses around OSFreeMem prevent the macro in allocmem.h from
* applying, as it would break the function's definition.
*/
void (OSFreeMem)(void *pvMem)
{
if (pvMem != NULL)
{
pvMem = _pvr_alloc_stats_remove(pvMem);
if (!is_vmalloc_addr(pvMem))
{
_pvr_kfree(pvMem);
}
else
{
_pvr_vfree(pvMem);
}
}
}
void *OSAllocMemNoStats(IMG_UINT32 ui32Size)
{
void *pvRet = NULL;
if (ui32Size <= g_ui32kmallocThreshold)
{
pvRet = kmalloc(ui32Size, GFP_KERNEL);
if (pvRet == NULL)
{
OSTryDecreaseKmallocThreshold();
}
else
{
OSResetKmallocFailCount();
}
}
if (pvRet == NULL)
{
pvRet = vmalloc(ui32Size);
}
return pvRet;
}
void *OSAllocZMemNoStats(IMG_UINT32 ui32Size)
{
void *pvRet = NULL;
if (ui32Size <= g_ui32kmallocThreshold)
{
pvRet = kzalloc(ui32Size, GFP_KERNEL);
if (pvRet == NULL)
{
OSTryDecreaseKmallocThreshold();
}
else
{
OSResetKmallocFailCount();
}
}
if (pvRet == NULL)
{
pvRet = vzalloc(ui32Size);
}
return pvRet;
}
/*
* The parentheses around OSFreeMemNoStats prevent the macro in allocmem.h from
* applying, as it would break the function's definition.
*/
void (OSFreeMemNoStats)(void *pvMem)
{
if (pvMem != NULL)
{
if (!is_vmalloc_addr(pvMem))
{
_pvr_kfree(pvMem);
}
else
{
_pvr_vfree(pvMem);
}
}
}

View File

@@ -0,0 +1,224 @@
/*************************************************************************/ /*!
@File allocmem.h
@Title memory allocation header
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Memory-Allocation API definitions
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef ALLOCMEM_H
#define ALLOCMEM_H
#include "img_types.h"
#include "pvr_debug.h"
#if defined(__cplusplus)
extern "C" {
#endif
/*
* PVRSRV_ENABLE_PROCESS_STATS enables process statistics regarding events,
* resources and memory across all processes
* PVRSRV_ENABLE_MEMORY_STATS enables recording of Linux kernel memory
* allocations, provided that PVRSRV_ENABLE_PROCESS_STATS is enabled
* - Output can be found in:
* /(sys/kernel/debug|proc)/pvr/proc_stats/[live|retired]_pids_stats/mem_area
* PVRSRV_DEBUG_LINUX_MEMORY_STATS provides more details about memory
* statistics in conjunction with PVRSRV_ENABLE_MEMORY_STATS
* PVRSRV_DEBUG_LINUX_MEMORY_STATS_ON is defined to encompass both memory
* allocation statistics functionalities described above in a single macro
*/
#if defined(PVRSRV_ENABLE_PROCESS_STATS) && defined(PVRSRV_ENABLE_MEMORY_STATS) && defined(PVRSRV_DEBUG_LINUX_MEMORY_STATS) && defined(DEBUG)
#define PVRSRV_DEBUG_LINUX_MEMORY_STATS_ON
#endif
/*
* When using detailed memory allocation statistics, the line number and
* file name where the allocation happened are also provided.
* When this feature is not used, these parameters are not needed.
*/
#if defined(PVRSRV_DEBUG_LINUX_MEMORY_STATS_ON)
#define DEBUG_MEMSTATS_PARAMS ,void *pvAllocFromFile, IMG_UINT32 ui32AllocFromLine
#define DEBUG_MEMSTATS_ARGS ,pvAllocFromFile, ui32AllocFromLine
#define DEBUG_MEMSTATS_UNREF (void)pvAllocFromFile; (void)ui32AllocFromLine;
#define DEBUG_MEMSTATS_VALUES ,__FILE__, __LINE__
#else
#define DEBUG_MEMSTATS_PARAMS /*!<
* Used for PVRSRV_DEBUG_LINUX_MEMORY_STATS_ON
* build option. */
#define DEBUG_MEMSTATS_ARGS /*!<
* Used for PVRSRV_DEBUG_LINUX_MEMORY_STATS_ON
* build option. */
#define DEBUG_MEMSTATS_UNREF /*!<
* Used for PVRSRV_DEBUG_LINUX_MEMORY_STATS_ON
* build option. */
#define DEBUG_MEMSTATS_VALUES /*!<
* Used for PVRSRV_DEBUG_LINUX_MEMORY_STATS_ON
* build option. */
#endif
/**************************************************************************/ /*!
@Function OSAllocMem
@Description Allocates CPU memory. Contents are uninitialized.
If passed a size of zero, function should not assert,
but just return a NULL pointer.
@Input ui32Size Size of required allocation (in bytes)
@Return Pointer to allocated memory on success.
Otherwise NULL.
*/ /**************************************************************************/
#if defined(DOXYGEN)
void *OSAllocMem(IMG_UINT32 ui32Size);
#else
void *OSAllocMem(IMG_UINT32 ui32Size DEBUG_MEMSTATS_PARAMS);
#define OSAllocMem(_size) (OSAllocMem)((_size) DEBUG_MEMSTATS_VALUES)
#endif
/**************************************************************************/ /*!
@Function OSAllocZMem
@Description Allocates CPU memory and initializes the contents to zero.
If passed a size of zero, function should not assert,
but just return a NULL pointer.
@Input ui32Size Size of required allocation (in bytes)
@Return Pointer to allocated memory on success.
Otherwise NULL.
*/ /**************************************************************************/
#if defined(DOXYGEN)
void *OSAllocZMem(IMG_UINT32 ui32Size);
#else
void *OSAllocZMem(IMG_UINT32 ui32Size DEBUG_MEMSTATS_PARAMS);
#define OSAllocZMem(_size) (OSAllocZMem)((_size) DEBUG_MEMSTATS_VALUES)
#endif
/**************************************************************************/ /*!
@Function OSAllocMemNoStats
@Description Allocates CPU memory. Contents are uninitialized.
If passed a size of zero, function should not assert,
but just return a NULL pointer.
The allocated memory is not accounted for by process stats.
Process stats are an optional feature (enabled only when
PVRSRV_ENABLE_PROCESS_STATS is defined) which track the amount
of memory allocated to help in debugging. Where this is not
required, OSAllocMem() and OSAllocMemNoStats() equate to
the same operation.
@Input ui32Size Size of required allocation (in bytes)
@Return Pointer to allocated memory on success.
Otherwise NULL.
*/ /**************************************************************************/
void *OSAllocMemNoStats(IMG_UINT32 ui32Size);
/**************************************************************************/ /*!
@Function OSAllocZMemNoStats
@Description Allocates CPU memory and initializes the contents to zero.
If passed a size of zero, function should not assert,
but just return a NULL pointer.
The allocated memory is not accounted for by process stats.
Process stats are an optional feature (enabled only when
PVRSRV_ENABLE_PROCESS_STATS is defined) which track the amount
of memory allocated to help in debugging. Where this is not
required, OSAllocZMem() and OSAllocZMemNoStats() equate to
the same operation.
@Input ui32Size Size of required allocation (in bytes)
@Return Pointer to allocated memory on success.
Otherwise NULL.
*/ /**************************************************************************/
void *OSAllocZMemNoStats(IMG_UINT32 ui32Size);
/**************************************************************************/ /*!
@Function OSFreeMem
@Description Frees previously allocated CPU memory.
@Input pvCpuVAddr Pointer to the memory to be freed.
@Return None.
*/ /**************************************************************************/
void OSFreeMem(void *pvCpuVAddr);
/**************************************************************************/ /*!
@Function OSFreeMemNoStats
@Description Frees previously allocated CPU memory.
The freed memory does not update the figures in process stats.
Process stats are an optional feature (enabled only when
PVRSRV_ENABLE_PROCESS_STATS is defined) which track the amount
of memory allocated to help in debugging. Where this is not
required, OSFreeMem() and OSFreeMemNoStats() equate to the
same operation.
@Input pvCpuVAddr Pointer to the memory to be freed.
@Return None.
*/ /**************************************************************************/
void OSFreeMemNoStats(void *pvCpuVAddr);
/*
* These macros allow us to catch double-free bugs on DEBUG builds and
* prevent crashes on RELEASE builds.
*/
/*! @cond Doxygen_Suppress */
#if defined(DEBUG)
#define double_free_sentinel ((void *)&OSFreeMem)
#define ALLOCMEM_ASSERT(exp) PVR_ASSERT(exp)
#else
#define double_free_sentinel NULL
#define ALLOCMEM_ASSERT(exp) do {} while (0)
#endif
/*! @endcond */
/*! Frees memory allocated by OSAllocMem(). */
#define OSFreeMem(_ptr) do { \
ALLOCMEM_ASSERT((_ptr) != double_free_sentinel); \
(OSFreeMem)(_ptr); \
(_ptr) = double_free_sentinel; \
MSC_SUPPRESS_4127 \
} while (0)
/*! Frees memory allocated by OSAllocMemNoStats(). */
#define OSFreeMemNoStats(_ptr) do { \
ALLOCMEM_ASSERT((_ptr) != double_free_sentinel); \
(OSFreeMemNoStats)(_ptr); \
(_ptr) = double_free_sentinel; \
MSC_SUPPRESS_4127 \
} while (0)
#if defined(__cplusplus)
}
#endif
#endif /* ALLOCMEM_H */
/******************************************************************************
End of file (allocmem.h)
******************************************************************************/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,151 @@
/*************************************************************************/ /*!
@File cache_km.h
@Title CPU cache management header
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef CACHE_KM_H
#define CACHE_KM_H
#if defined(__linux__)
#include <linux/version.h>
#else
#define KERNEL_VERSION
#endif
#include "pvrsrv_error.h"
#include "os_cpu_cache.h"
#include "img_types.h"
#include "cache_ops.h"
#include "device.h"
#include "pmr.h"
typedef IMG_UINT32 PVRSRV_CACHE_OP_ADDR_TYPE; /*!< Represents CPU address type required for CPU d-cache maintenance */
#define PVRSRV_CACHE_OP_ADDR_TYPE_VIRTUAL 0x1 /*!< Operation requires CPU virtual address only */
#define PVRSRV_CACHE_OP_ADDR_TYPE_PHYSICAL 0x2 /*!< Operation requires CPU physical address only */
#define PVRSRV_CACHE_OP_ADDR_TYPE_BOTH 0x3 /*!< Operation requires both CPU virtual & physical addresses */
#include "connection_server.h"
/*
* CacheOpInit() & CacheOpDeInit()
*
* This must be called to initialise the KM cache maintenance framework.
* This is called early during the driver/module (un)loading phase.
*/
PVRSRV_ERROR CacheOpInit(void);
void CacheOpDeInit(void);
/*
* CacheOpInit2() & CacheOpDeInit2()
*
* This must be called to initialise the UM cache maintenance framework.
* This is called when the driver is loaded/unloaded from the kernel.
*/
PVRSRV_ERROR CacheOpInit2(void);
void CacheOpDeInit2(void);
/*
* CacheOpExec()
*
* This is the primary CPU data-cache maintenance interface and it is
* always guaranteed to be synchronous; the arguments supplied must be
* pre-validated for performance reasons else the d-cache maintenance
* operation might cause the underlying OS kernel to fault.
*/
PVRSRV_ERROR CacheOpExec(PPVRSRV_DEVICE_NODE psDevNode,
void *pvVirtStart,
void *pvVirtEnd,
IMG_CPU_PHYADDR sCPUPhysStart,
IMG_CPU_PHYADDR sCPUPhysEnd,
PVRSRV_CACHE_OP uiCacheOp);
/*
* CacheOpValExec()
*
* Same as CacheOpExec(), except arguments are _Validated_ before being
* presented to the underlying OS kernel for CPU data-cache maintenance.
* The uiAddress is the start CPU virtual address for the to-be d-cache
* maintained PMR, it can be NULL in which case a remap will be performed
* internally, if required for cache maintenance. This is primarily used
* as the services client bridge call handler for synchronous user-mode
* cache maintenance requests.
*/
PVRSRV_ERROR CacheOpValExec(PMR *psPMR,
IMG_UINT64 uiAddress,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize,
PVRSRV_CACHE_OP uiCacheOp);
/*
* CacheOpQueue()
*
* This is the secondary cache maintenance interface and it is not
* guaranteed to be synchronous in that requests could be deferred
* and executed asynchronously. This interface is primarily meant
* as services client bridge call handler. Both uiInfoPgGFSeqNum
* and ui32[Current,Next]FenceSeqNum implements an internal client
* server queueing protocol so making use of this interface outside
* of services client is not recommended and should not be done.
*/
PVRSRV_ERROR CacheOpQueue(CONNECTION_DATA *psConnection,
PPVRSRV_DEVICE_NODE psDevNode,
IMG_UINT32 ui32OpCount,
PMR **ppsPMR,
IMG_UINT64 *puiAddress,
IMG_DEVMEM_OFFSET_T *puiOffset,
IMG_DEVMEM_SIZE_T *puiSize,
PVRSRV_CACHE_OP *puiCacheOp,
IMG_UINT32 ui32OpTimeline);
/*
* CacheOpLog()
*
* This is used for logging client cache maintenance operations that
* was executed in user-space.
*/
PVRSRV_ERROR CacheOpLog(PMR *psPMR,
IMG_UINT64 uiAddress,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize,
IMG_UINT64 ui64StartTime,
IMG_UINT64 ui64EndTime,
PVRSRV_CACHE_OP uiCacheOp);
#endif /* CACHE_KM_H */

View File

@@ -0,0 +1,61 @@
/*************************************************************************/ /*!
@File
@Title Services cache management header
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Defines for cache management which are visible internally
and externally
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef CACHE_OPS_H
#define CACHE_OPS_H
#include "img_types.h"
/*!
* @Defgroup CPUCacheAPIs
* @{
*/
#define CACHE_BATCH_MAX (8U)
#define MAX_DMA_OPS (34)
typedef IMG_UINT32 PVRSRV_CACHE_OP; /*!< Type represents cache maintenance operation */
#define PVRSRV_CACHE_OP_NONE 0x0U /*!< No operation */
#define PVRSRV_CACHE_OP_CLEAN 0x1U /*!< Flush w/o invalidate */
#define PVRSRV_CACHE_OP_INVALIDATE 0x2U /*!< Invalidate w/o flush */
#define PVRSRV_CACHE_OP_FLUSH 0x3U /*!< Flush w/ invalidate */
/*! @} End of Defgroup CPUCacheAPIs */
#endif /* CACHE_OPS_H */

View File

@@ -0,0 +1,80 @@
/*******************************************************************************
@File
@Title Client bridge header for cache
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Exports the client bridge functions for cache
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef CLIENT_CACHE_BRIDGE_H
#define CLIENT_CACHE_BRIDGE_H
#include "img_defs.h"
#include "pvrsrv_error.h"
#if defined(PVR_INDIRECT_BRIDGE_CLIENTS)
#include "pvr_bridge_client.h"
#include "pvr_bridge.h"
#endif
#include "common_cache_bridge.h"
IMG_INTERNAL PVRSRV_ERROR BridgeCacheOpQueue(IMG_HANDLE hBridge,
IMG_UINT32 ui32NumCacheOps,
IMG_HANDLE * phPMR,
IMG_UINT64 * pui64Address,
IMG_DEVMEM_OFFSET_T * puiOffset,
IMG_DEVMEM_SIZE_T * puiSize,
PVRSRV_CACHE_OP * piuCacheOp,
IMG_UINT32 ui32OpTimeline);
IMG_INTERNAL PVRSRV_ERROR BridgeCacheOpExec(IMG_HANDLE hBridge,
IMG_HANDLE hPMR,
IMG_UINT64 ui64Address,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize, PVRSRV_CACHE_OP iuCacheOp);
IMG_INTERNAL PVRSRV_ERROR BridgeCacheOpLog(IMG_HANDLE hBridge,
IMG_HANDLE hPMR,
IMG_UINT64 ui64Address,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize,
IMG_INT64 i64StartTime,
IMG_INT64 i64EndTime, PVRSRV_CACHE_OP iuCacheOp);
#endif /* CLIENT_CACHE_BRIDGE_H */

View File

@@ -0,0 +1,111 @@
/*******************************************************************************
@File
@Title Direct client bridge for cache
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Implements the client side of the bridge for cache
which is used in calls from Server context.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#include "client_cache_bridge.h"
#include "img_defs.h"
#include "pvr_debug.h"
/* Module specific includes */
#include "cache_ops.h"
#include "cache_km.h"
IMG_INTERNAL PVRSRV_ERROR BridgeCacheOpQueue(IMG_HANDLE hBridge,
IMG_UINT32 ui32NumCacheOps,
IMG_HANDLE *phPMR,
IMG_UINT64 *pui64Address,
IMG_DEVMEM_OFFSET_T *puiOffset,
IMG_DEVMEM_SIZE_T *puiSize,
PVRSRV_CACHE_OP *piuCacheOp, IMG_UINT32 ui32OpTimeline)
{
PVRSRV_ERROR eError;
PMR **psPMRInt;
psPMRInt = (PMR **) phPMR;
eError =
CacheOpQueue(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
ui32NumCacheOps,
psPMRInt, pui64Address, puiOffset, puiSize, piuCacheOp, ui32OpTimeline);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeCacheOpExec(IMG_HANDLE hBridge,
IMG_HANDLE hPMR,
IMG_UINT64 ui64Address,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize, PVRSRV_CACHE_OP iuCacheOp)
{
PVRSRV_ERROR eError;
PMR *psPMRInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psPMRInt = (PMR *) hPMR;
eError = CacheOpValExec(psPMRInt, ui64Address, uiOffset, uiSize, iuCacheOp);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeCacheOpLog(IMG_HANDLE hBridge,
IMG_HANDLE hPMR,
IMG_UINT64 ui64Address,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize,
IMG_INT64 i64StartTime,
IMG_INT64 i64EndTime, PVRSRV_CACHE_OP iuCacheOp)
{
PVRSRV_ERROR eError;
PMR *psPMRInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psPMRInt = (PMR *) hPMR;
eError =
CacheOpLog(psPMRInt,
ui64Address, uiOffset, uiSize, i64StartTime, i64EndTime, iuCacheOp);
return eError;
}

View File

@@ -0,0 +1,111 @@
/*******************************************************************************
@File
@Title Client bridge header for devicememhistory
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Exports the client bridge functions for devicememhistory
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef CLIENT_DEVICEMEMHISTORY_BRIDGE_H
#define CLIENT_DEVICEMEMHISTORY_BRIDGE_H
#include "img_defs.h"
#include "pvrsrv_error.h"
#if defined(PVR_INDIRECT_BRIDGE_CLIENTS)
#include "pvr_bridge_client.h"
#include "pvr_bridge.h"
#endif
#include "common_devicememhistory_bridge.h"
IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistoryMap(IMG_HANDLE hBridge,
IMG_HANDLE hPMR,
IMG_DEVMEM_SIZE_T uiOffset,
IMG_DEV_VIRTADDR sDevVAddr,
IMG_DEVMEM_SIZE_T uiSize,
const IMG_CHAR * puiText,
IMG_UINT32 ui32Log2PageSize,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 * pui32AllocationIndexOut);
IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistoryUnmap(IMG_HANDLE hBridge,
IMG_HANDLE hPMR,
IMG_DEVMEM_SIZE_T uiOffset,
IMG_DEV_VIRTADDR sDevVAddr,
IMG_DEVMEM_SIZE_T uiSize,
const IMG_CHAR * puiText,
IMG_UINT32 ui32Log2PageSize,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 * pui32AllocationIndexOut);
IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistoryMapVRange(IMG_HANDLE hBridge,
IMG_DEV_VIRTADDR sBaseDevVAddr,
IMG_UINT32 ui32ui32StartPage,
IMG_UINT32 ui32NumPages,
IMG_DEVMEM_SIZE_T uiAllocSize,
const IMG_CHAR * puiText,
IMG_UINT32 ui32Log2PageSize,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 * pui32AllocationIndexOut);
IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistoryUnmapVRange(IMG_HANDLE hBridge,
IMG_DEV_VIRTADDR sBaseDevVAddr,
IMG_UINT32 ui32ui32StartPage,
IMG_UINT32 ui32NumPages,
IMG_DEVMEM_SIZE_T uiAllocSize,
const IMG_CHAR * puiText,
IMG_UINT32 ui32Log2PageSize,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 * pui32AllocationIndexOut);
IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistorySparseChange(IMG_HANDLE hBridge,
IMG_HANDLE hPMR,
IMG_DEVMEM_SIZE_T uiOffset,
IMG_DEV_VIRTADDR sDevVAddr,
IMG_DEVMEM_SIZE_T uiSize,
const IMG_CHAR * puiText,
IMG_UINT32 ui32Log2PageSize,
IMG_UINT32 ui32AllocPageCount,
IMG_UINT32 * pui32AllocPageIndices,
IMG_UINT32 ui32FreePageCount,
IMG_UINT32 * pui32FreePageIndices,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 * pui32AllocationIndexOut);
#endif /* CLIENT_DEVICEMEMHISTORY_BRIDGE_H */

View File

@@ -0,0 +1,195 @@
/*******************************************************************************
@File
@Title Direct client bridge for devicememhistory
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Implements the client side of the bridge for devicememhistory
which is used in calls from Server context.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#include "client_devicememhistory_bridge.h"
#include "img_defs.h"
#include "pvr_debug.h"
/* Module specific includes */
#include "img_types.h"
#include "img_defs.h"
#include "devicemem_typedefs.h"
#include "pmr.h"
#include "devicemem_history_server.h"
IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistoryMap(IMG_HANDLE hBridge,
IMG_HANDLE hPMR,
IMG_DEVMEM_SIZE_T uiOffset,
IMG_DEV_VIRTADDR sDevVAddr,
IMG_DEVMEM_SIZE_T uiSize,
const IMG_CHAR *puiText,
IMG_UINT32 ui32Log2PageSize,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 *pui32AllocationIndexOut)
{
PVRSRV_ERROR eError;
PMR *psPMRInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psPMRInt = (PMR *) hPMR;
eError =
DevicememHistoryMapKM(psPMRInt,
uiOffset,
sDevVAddr,
uiSize,
puiText,
ui32Log2PageSize, ui32AllocationIndex, pui32AllocationIndexOut);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistoryUnmap(IMG_HANDLE hBridge,
IMG_HANDLE hPMR,
IMG_DEVMEM_SIZE_T uiOffset,
IMG_DEV_VIRTADDR sDevVAddr,
IMG_DEVMEM_SIZE_T uiSize,
const IMG_CHAR *puiText,
IMG_UINT32 ui32Log2PageSize,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 *pui32AllocationIndexOut)
{
PVRSRV_ERROR eError;
PMR *psPMRInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psPMRInt = (PMR *) hPMR;
eError =
DevicememHistoryUnmapKM(psPMRInt,
uiOffset,
sDevVAddr,
uiSize,
puiText,
ui32Log2PageSize, ui32AllocationIndex, pui32AllocationIndexOut);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistoryMapVRange(IMG_HANDLE hBridge,
IMG_DEV_VIRTADDR sBaseDevVAddr,
IMG_UINT32 ui32ui32StartPage,
IMG_UINT32 ui32NumPages,
IMG_DEVMEM_SIZE_T uiAllocSize,
const IMG_CHAR *puiText,
IMG_UINT32 ui32Log2PageSize,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 *pui32AllocationIndexOut)
{
PVRSRV_ERROR eError;
eError =
DevicememHistoryMapVRangeKM(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
sBaseDevVAddr,
ui32ui32StartPage,
ui32NumPages,
uiAllocSize,
puiText,
ui32Log2PageSize,
ui32AllocationIndex, pui32AllocationIndexOut);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistoryUnmapVRange(IMG_HANDLE hBridge,
IMG_DEV_VIRTADDR sBaseDevVAddr,
IMG_UINT32 ui32ui32StartPage,
IMG_UINT32 ui32NumPages,
IMG_DEVMEM_SIZE_T uiAllocSize,
const IMG_CHAR *puiText,
IMG_UINT32 ui32Log2PageSize,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 *pui32AllocationIndexOut)
{
PVRSRV_ERROR eError;
eError =
DevicememHistoryUnmapVRangeKM(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
sBaseDevVAddr,
ui32ui32StartPage,
ui32NumPages,
uiAllocSize,
puiText,
ui32Log2PageSize,
ui32AllocationIndex, pui32AllocationIndexOut);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistorySparseChange(IMG_HANDLE hBridge,
IMG_HANDLE hPMR,
IMG_DEVMEM_SIZE_T uiOffset,
IMG_DEV_VIRTADDR sDevVAddr,
IMG_DEVMEM_SIZE_T uiSize,
const IMG_CHAR *puiText,
IMG_UINT32 ui32Log2PageSize,
IMG_UINT32 ui32AllocPageCount,
IMG_UINT32 *pui32AllocPageIndices,
IMG_UINT32 ui32FreePageCount,
IMG_UINT32 *pui32FreePageIndices,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 *pui32AllocationIndexOut)
{
PVRSRV_ERROR eError;
PMR *psPMRInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psPMRInt = (PMR *) hPMR;
eError =
DevicememHistorySparseChangeKM(psPMRInt,
uiOffset,
sDevVAddr,
uiSize,
puiText,
ui32Log2PageSize,
ui32AllocPageCount,
pui32AllocPageIndices,
ui32FreePageCount,
pui32FreePageIndices,
ui32AllocationIndex, pui32AllocationIndexOut);
return eError;
}

View File

@@ -0,0 +1,64 @@
/*******************************************************************************
@File
@Title Client bridge header for htbuffer
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Exports the client bridge functions for htbuffer
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef CLIENT_HTBUFFER_BRIDGE_H
#define CLIENT_HTBUFFER_BRIDGE_H
#include "img_defs.h"
#include "pvrsrv_error.h"
#if defined(PVR_INDIRECT_BRIDGE_CLIENTS)
#include "pvr_bridge_client.h"
#include "pvr_bridge.h"
#endif
#include "common_htbuffer_bridge.h"
IMG_INTERNAL PVRSRV_ERROR BridgeHTBControl(IMG_HANDLE hBridge,
IMG_UINT32 ui32NumGroups,
IMG_UINT32 * pui32GroupEnable,
IMG_UINT32 ui32LogLevel,
IMG_UINT32 ui32EnablePID,
IMG_UINT32 ui32LogMode, IMG_UINT32 ui32OpMode);
#endif /* CLIENT_HTBUFFER_BRIDGE_H */

View File

@@ -0,0 +1,70 @@
/*******************************************************************************
@File
@Title Direct client bridge for htbuffer
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Implements the client side of the bridge for htbuffer
which is used in calls from Server context.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#include "client_htbuffer_bridge.h"
#include "img_defs.h"
#include "pvr_debug.h"
/* Module specific includes */
#include "devicemem_typedefs.h"
#include "htbuffer_types.h"
#include "htbserver.h"
IMG_INTERNAL PVRSRV_ERROR BridgeHTBControl(IMG_HANDLE hBridge,
IMG_UINT32 ui32NumGroups,
IMG_UINT32 *pui32GroupEnable,
IMG_UINT32 ui32LogLevel,
IMG_UINT32 ui32EnablePID,
IMG_UINT32 ui32LogMode, IMG_UINT32 ui32OpMode)
{
PVRSRV_ERROR eError;
PVR_UNREFERENCED_PARAMETER(hBridge);
eError =
HTBControlKM(ui32NumGroups,
pui32GroupEnable, ui32LogLevel, ui32EnablePID, ui32LogMode, ui32OpMode);
return eError;
}

View File

@@ -0,0 +1,229 @@
/*******************************************************************************
@File
@Title Client bridge header for mm
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Exports the client bridge functions for mm
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef CLIENT_MM_BRIDGE_H
#define CLIENT_MM_BRIDGE_H
#include "img_defs.h"
#include "pvrsrv_error.h"
#if defined(PVR_INDIRECT_BRIDGE_CLIENTS)
#include "pvr_bridge_client.h"
#include "pvr_bridge.h"
#endif
#include "common_mm_bridge.h"
IMG_INTERNAL PVRSRV_ERROR BridgePMRExportPMR(IMG_HANDLE hBridge,
IMG_HANDLE hPMR,
IMG_HANDLE * phPMRExport,
IMG_UINT64 * pui64Size,
IMG_UINT32 * pui32Log2Contig,
IMG_UINT64 * pui64Password);
IMG_INTERNAL PVRSRV_ERROR BridgePMRUnexportPMR(IMG_HANDLE hBridge, IMG_HANDLE hPMRExport);
IMG_INTERNAL PVRSRV_ERROR BridgePMRGetUID(IMG_HANDLE hBridge,
IMG_HANDLE hPMR, IMG_UINT64 * pui64UID);
IMG_INTERNAL PVRSRV_ERROR BridgePMRMakeLocalImportHandle(IMG_HANDLE hBridge,
IMG_HANDLE hBuffer, IMG_HANDLE * phExtMem);
IMG_INTERNAL PVRSRV_ERROR BridgePMRUnmakeLocalImportHandle(IMG_HANDLE hBridge, IMG_HANDLE hExtMem);
IMG_INTERNAL PVRSRV_ERROR BridgePMRImportPMR(IMG_HANDLE hBridge,
IMG_HANDLE hPMRExport,
IMG_UINT64 ui64uiPassword,
IMG_UINT64 ui64uiSize,
IMG_UINT32 ui32uiLog2Contig, IMG_HANDLE * phPMR);
IMG_INTERNAL PVRSRV_ERROR BridgePMRLocalImportPMR(IMG_HANDLE hBridge,
IMG_HANDLE hExtHandle,
IMG_HANDLE * phPMR,
IMG_DEVMEM_SIZE_T * puiSize,
IMG_DEVMEM_ALIGN_T * puiAlign);
IMG_INTERNAL PVRSRV_ERROR BridgePMRUnrefPMR(IMG_HANDLE hBridge, IMG_HANDLE hPMR);
IMG_INTERNAL PVRSRV_ERROR BridgePhysmemNewRamBackedPMR(IMG_HANDLE hBridge,
IMG_DEVMEM_SIZE_T uiSize,
IMG_UINT32 ui32NumPhysChunks,
IMG_UINT32 ui32NumVirtChunks,
IMG_UINT32 * pui32MappingTable,
IMG_UINT32 ui32Log2PageSize,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
IMG_UINT32 ui32AnnotationLength,
const IMG_CHAR * puiAnnotation,
IMG_PID ui32PID,
IMG_HANDLE * phPMRPtr,
IMG_UINT32 ui32PDumpFlags,
PVRSRV_MEMALLOCFLAGS_T * puiOutFlags);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntCtxCreate(IMG_HANDLE hBridge,
IMG_BOOL bbKernelMemoryCtx,
IMG_HANDLE * phDevMemServerContext,
IMG_HANDLE * phPrivData,
IMG_UINT32 * pui32CPUCacheLineSize);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntCtxDestroy(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemServerContext);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntHeapCreate(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemCtx,
IMG_UINT32 ui32HeapConfigIndex,
IMG_UINT32 ui32HeapIndex,
IMG_HANDLE * phDevmemHeapPtr);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntHeapDestroy(IMG_HANDLE hBridge, IMG_HANDLE hDevmemHeap);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntMapPMR(IMG_HANDLE hBridge,
IMG_HANDLE hReservation, IMG_HANDLE hPMR);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntUnmapPMR(IMG_HANDLE hBridge, IMG_HANDLE hReservation);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntReserveRange(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemServerHeap,
IMG_DEV_VIRTADDR sAddress,
IMG_DEVMEM_SIZE_T uiLength,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
IMG_HANDLE * phReservation);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntReserveRangeAndMapPMR(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemServerHeap,
IMG_DEV_VIRTADDR sAddress,
IMG_DEVMEM_SIZE_T uiLength,
IMG_HANDLE hPMR,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
IMG_HANDLE * phReservation);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntUnreserveRange(IMG_HANDLE hBridge,
IMG_HANDLE hReservation);
IMG_INTERNAL PVRSRV_ERROR BridgeChangeSparseMem(IMG_HANDLE hBridge,
IMG_UINT32 ui32AllocPageCount,
IMG_UINT32 * pui32AllocPageIndices,
IMG_UINT32 ui32FreePageCount,
IMG_UINT32 * pui32FreePageIndices,
IMG_UINT32 ui32SparseFlags,
IMG_HANDLE hReservation);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIsVDevAddrValid(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemCtx,
IMG_DEV_VIRTADDR sAddress);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemInvalidateFBSCTable(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemCtx,
IMG_UINT64 ui64FBSCEntries);
IMG_INTERNAL PVRSRV_ERROR BridgeHeapCfgHeapConfigCount(IMG_HANDLE hBridge,
IMG_UINT32 * pui32NumHeapConfigs);
IMG_INTERNAL PVRSRV_ERROR BridgeHeapCfgHeapCount(IMG_HANDLE hBridge,
IMG_UINT32 ui32HeapConfigIndex,
IMG_UINT32 * pui32NumHeaps);
IMG_INTERNAL PVRSRV_ERROR BridgeHeapCfgHeapConfigName(IMG_HANDLE hBridge,
IMG_UINT32 ui32HeapConfigIndex,
IMG_UINT32 ui32HeapConfigNameBufSz,
IMG_CHAR * puiHeapConfigName);
IMG_INTERNAL PVRSRV_ERROR BridgeHeapCfgHeapDetails(IMG_HANDLE hBridge,
IMG_UINT32 ui32HeapConfigIndex,
IMG_UINT32 ui32HeapIndex,
IMG_UINT32 ui32HeapNameBufSz,
IMG_CHAR * puiHeapNameOut,
IMG_DEV_VIRTADDR * psDevVAddrBase,
IMG_DEVMEM_SIZE_T * puiHeapLength,
IMG_DEVMEM_SIZE_T * puiReservedRegionLength,
IMG_UINT32 * pui32Log2DataPageSizeOut,
IMG_UINT32 * pui32Log2ImportAlignmentOut);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntRegisterPFNotifyKM(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemCtx,
IMG_BOOL bRegister);
IMG_INTERNAL PVRSRV_ERROR BridgePhysHeapGetMemInfo(IMG_HANDLE hBridge,
IMG_UINT32 ui32PhysHeapCount,
PVRSRV_PHYS_HEAP * peaPhysHeapID,
PHYS_HEAP_MEM_STATS * pasapPhysHeapMemStats);
IMG_INTERNAL PVRSRV_ERROR BridgeGetDefaultPhysicalHeap(IMG_HANDLE hBridge,
PVRSRV_PHYS_HEAP * peHeap);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemGetFaultAddress(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemCtx,
IMG_DEV_VIRTADDR * psFaultAddress);
IMG_INTERNAL PVRSRV_ERROR BridgePVRSRVStatsUpdateOOMStat(IMG_HANDLE hBridge,
IMG_UINT32 ui32ui32StatType,
IMG_PID ui32pid);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemXIntReserveRange(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemServerHeap,
IMG_DEV_VIRTADDR sAddress,
IMG_DEVMEM_SIZE_T uiLength,
IMG_HANDLE * phReservation);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemXIntUnreserveRange(IMG_HANDLE hBridge,
IMG_HANDLE hReservation);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemXIntMapPages(IMG_HANDLE hBridge,
IMG_HANDLE hReservation,
IMG_HANDLE hPMR,
IMG_UINT32 ui32PageCount,
IMG_UINT32 ui32PhysPageOffset,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
IMG_UINT32 ui32VirtPageOffset);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemXIntUnmapPages(IMG_HANDLE hBridge,
IMG_HANDLE hReservation,
IMG_UINT32 ui32VirtPageOffset,
IMG_UINT32 ui32PageCount);
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemXIntMapVRangeToBackingPage(IMG_HANDLE hBridge,
IMG_HANDLE hReservation,
IMG_UINT32 ui32PageCount,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
IMG_UINT32 ui32VirtPageOffset);
#endif /* CLIENT_MM_BRIDGE_H */

View File

@@ -0,0 +1,702 @@
/*******************************************************************************
@File
@Title Direct client bridge for mm
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Implements the client side of the bridge for mm
which is used in calls from Server context.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#include "client_mm_bridge.h"
#include "img_defs.h"
#include "pvr_debug.h"
/* Module specific includes */
#include "pvrsrv_memallocflags.h"
#include "pvrsrv_memalloc_physheap.h"
#include "devicemem_typedefs.h"
#include "pvrsrv_memalloc_physheap.h"
#include "devicemem.h"
#include "devicemem_server.h"
#include "pmr.h"
#include "devicemem_heapcfg.h"
#include "physmem.h"
#include "devicemem_utils.h"
#include "process_stats.h"
IMG_INTERNAL PVRSRV_ERROR BridgePMRExportPMR(IMG_HANDLE hBridge,
IMG_HANDLE hPMR,
IMG_HANDLE *phPMRExport,
IMG_UINT64 *pui64Size,
IMG_UINT32 *pui32Log2Contig, IMG_UINT64 *pui64Password)
{
#if defined(SUPPORT_INSECURE_EXPORT)
PVRSRV_ERROR eError;
PMR *psPMRInt;
PMR_EXPORT *psPMRExportInt = NULL;
PVR_UNREFERENCED_PARAMETER(hBridge);
psPMRInt = (PMR *) hPMR;
eError = PMRExportPMR(psPMRInt, &psPMRExportInt, pui64Size, pui32Log2Contig, pui64Password);
*phPMRExport = psPMRExportInt;
return eError;
#else
PVR_UNREFERENCED_PARAMETER(hBridge);
PVR_UNREFERENCED_PARAMETER(hPMR);
PVR_UNREFERENCED_PARAMETER(phPMRExport);
PVR_UNREFERENCED_PARAMETER(pui64Size);
PVR_UNREFERENCED_PARAMETER(pui32Log2Contig);
PVR_UNREFERENCED_PARAMETER(pui64Password);
return PVRSRV_ERROR_NOT_IMPLEMENTED;
#endif
}
IMG_INTERNAL PVRSRV_ERROR BridgePMRUnexportPMR(IMG_HANDLE hBridge, IMG_HANDLE hPMRExport)
{
#if defined(SUPPORT_INSECURE_EXPORT)
PVRSRV_ERROR eError;
PMR_EXPORT *psPMRExportInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psPMRExportInt = (PMR_EXPORT *) hPMRExport;
eError = PMRUnexportPMR(psPMRExportInt);
return eError;
#else
PVR_UNREFERENCED_PARAMETER(hBridge);
PVR_UNREFERENCED_PARAMETER(hPMRExport);
return PVRSRV_ERROR_NOT_IMPLEMENTED;
#endif
}
IMG_INTERNAL PVRSRV_ERROR BridgePMRGetUID(IMG_HANDLE hBridge, IMG_HANDLE hPMR, IMG_UINT64 *pui64UID)
{
PVRSRV_ERROR eError;
PMR *psPMRInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psPMRInt = (PMR *) hPMR;
eError = PMRGetUID(psPMRInt, pui64UID);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgePMRMakeLocalImportHandle(IMG_HANDLE hBridge,
IMG_HANDLE hBuffer, IMG_HANDLE *phExtMem)
{
PVRSRV_ERROR eError;
PMR *psBufferInt;
PMR *psExtMemInt = NULL;
PVR_UNREFERENCED_PARAMETER(hBridge);
psBufferInt = (PMR *) hBuffer;
eError = PMRMakeLocalImportHandle(psBufferInt, &psExtMemInt);
*phExtMem = psExtMemInt;
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgePMRUnmakeLocalImportHandle(IMG_HANDLE hBridge, IMG_HANDLE hExtMem)
{
PVRSRV_ERROR eError;
PMR *psExtMemInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psExtMemInt = (PMR *) hExtMem;
eError = PMRUnmakeLocalImportHandle(psExtMemInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgePMRImportPMR(IMG_HANDLE hBridge,
IMG_HANDLE hPMRExport,
IMG_UINT64 ui64uiPassword,
IMG_UINT64 ui64uiSize,
IMG_UINT32 ui32uiLog2Contig, IMG_HANDLE *phPMR)
{
#if defined(SUPPORT_INSECURE_EXPORT)
PVRSRV_ERROR eError;
PMR_EXPORT *psPMRExportInt;
PMR *psPMRInt = NULL;
psPMRExportInt = (PMR_EXPORT *) hPMRExport;
eError =
PhysmemImportPMR(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
psPMRExportInt,
ui64uiPassword, ui64uiSize, ui32uiLog2Contig, &psPMRInt);
*phPMR = psPMRInt;
return eError;
#else
PVR_UNREFERENCED_PARAMETER(hPMRExport);
PVR_UNREFERENCED_PARAMETER(ui64uiPassword);
PVR_UNREFERENCED_PARAMETER(ui64uiSize);
PVR_UNREFERENCED_PARAMETER(ui32uiLog2Contig);
PVR_UNREFERENCED_PARAMETER(phPMR);
return PVRSRV_ERROR_NOT_IMPLEMENTED;
#endif
}
IMG_INTERNAL PVRSRV_ERROR BridgePMRLocalImportPMR(IMG_HANDLE hBridge,
IMG_HANDLE hExtHandle,
IMG_HANDLE *phPMR,
IMG_DEVMEM_SIZE_T *puiSize,
IMG_DEVMEM_ALIGN_T *puiAlign)
{
PVRSRV_ERROR eError;
PMR *psExtHandleInt;
PMR *psPMRInt = NULL;
PVR_UNREFERENCED_PARAMETER(hBridge);
psExtHandleInt = (PMR *) hExtHandle;
eError = PMRLocalImportPMR(psExtHandleInt, &psPMRInt, puiSize, puiAlign);
*phPMR = psPMRInt;
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgePMRUnrefPMR(IMG_HANDLE hBridge, IMG_HANDLE hPMR)
{
PVRSRV_ERROR eError;
PMR *psPMRInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psPMRInt = (PMR *) hPMR;
eError = PMRUnrefPMR(psPMRInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgePhysmemNewRamBackedPMR(IMG_HANDLE hBridge,
IMG_DEVMEM_SIZE_T uiSize,
IMG_UINT32 ui32NumPhysChunks,
IMG_UINT32 ui32NumVirtChunks,
IMG_UINT32 *pui32MappingTable,
IMG_UINT32 ui32Log2PageSize,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
IMG_UINT32 ui32AnnotationLength,
const IMG_CHAR *puiAnnotation,
IMG_PID ui32PID,
IMG_HANDLE *phPMRPtr,
IMG_UINT32 ui32PDumpFlags,
PVRSRV_MEMALLOCFLAGS_T *puiOutFlags)
{
PVRSRV_ERROR eError;
PMR *psPMRPtrInt = NULL;
eError =
PhysmemNewRamBackedPMR_direct(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
uiSize,
ui32NumPhysChunks,
ui32NumVirtChunks,
pui32MappingTable,
ui32Log2PageSize,
uiFlags,
ui32AnnotationLength,
puiAnnotation,
ui32PID, &psPMRPtrInt, ui32PDumpFlags, puiOutFlags);
*phPMRPtr = psPMRPtrInt;
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntCtxCreate(IMG_HANDLE hBridge,
IMG_BOOL bbKernelMemoryCtx,
IMG_HANDLE *phDevMemServerContext,
IMG_HANDLE *phPrivData,
IMG_UINT32 *pui32CPUCacheLineSize)
{
PVRSRV_ERROR eError;
DEVMEMINT_CTX *psDevMemServerContextInt = NULL;
IMG_HANDLE hPrivDataInt = NULL;
eError =
DevmemIntCtxCreate(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
bbKernelMemoryCtx,
&psDevMemServerContextInt, &hPrivDataInt, pui32CPUCacheLineSize);
*phDevMemServerContext = psDevMemServerContextInt;
*phPrivData = hPrivDataInt;
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntCtxDestroy(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemServerContext)
{
PVRSRV_ERROR eError;
DEVMEMINT_CTX *psDevmemServerContextInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psDevmemServerContextInt = (DEVMEMINT_CTX *) hDevmemServerContext;
eError = DevmemIntCtxDestroy(psDevmemServerContextInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntHeapCreate(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemCtx,
IMG_UINT32 ui32HeapConfigIndex,
IMG_UINT32 ui32HeapIndex,
IMG_HANDLE *phDevmemHeapPtr)
{
PVRSRV_ERROR eError;
DEVMEMINT_CTX *psDevmemCtxInt;
DEVMEMINT_HEAP *psDevmemHeapPtrInt = NULL;
PVR_UNREFERENCED_PARAMETER(hBridge);
psDevmemCtxInt = (DEVMEMINT_CTX *) hDevmemCtx;
eError =
DevmemIntHeapCreate(psDevmemCtxInt,
ui32HeapConfigIndex, ui32HeapIndex, &psDevmemHeapPtrInt);
*phDevmemHeapPtr = psDevmemHeapPtrInt;
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntHeapDestroy(IMG_HANDLE hBridge, IMG_HANDLE hDevmemHeap)
{
PVRSRV_ERROR eError;
DEVMEMINT_HEAP *psDevmemHeapInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psDevmemHeapInt = (DEVMEMINT_HEAP *) hDevmemHeap;
eError = DevmemIntHeapDestroy(psDevmemHeapInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntMapPMR(IMG_HANDLE hBridge,
IMG_HANDLE hReservation, IMG_HANDLE hPMR)
{
PVRSRV_ERROR eError;
DEVMEMINT_RESERVATION *psReservationInt;
PMR *psPMRInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psReservationInt = (DEVMEMINT_RESERVATION *) hReservation;
psPMRInt = (PMR *) hPMR;
eError = DevmemIntMapPMR(psReservationInt, psPMRInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntUnmapPMR(IMG_HANDLE hBridge, IMG_HANDLE hReservation)
{
PVRSRV_ERROR eError;
DEVMEMINT_RESERVATION *psReservationInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psReservationInt = (DEVMEMINT_RESERVATION *) hReservation;
eError = DevmemIntUnmapPMR(psReservationInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntReserveRange(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemServerHeap,
IMG_DEV_VIRTADDR sAddress,
IMG_DEVMEM_SIZE_T uiLength,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
IMG_HANDLE *phReservation)
{
PVRSRV_ERROR eError;
DEVMEMINT_HEAP *psDevmemServerHeapInt;
DEVMEMINT_RESERVATION *psReservationInt = NULL;
psDevmemServerHeapInt = (DEVMEMINT_HEAP *) hDevmemServerHeap;
eError =
DevmemIntReserveRange(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
psDevmemServerHeapInt,
sAddress, uiLength, uiFlags, &psReservationInt);
*phReservation = psReservationInt;
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntReserveRangeAndMapPMR(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemServerHeap,
IMG_DEV_VIRTADDR sAddress,
IMG_DEVMEM_SIZE_T uiLength,
IMG_HANDLE hPMR,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
IMG_HANDLE *phReservation)
{
PVRSRV_ERROR eError;
DEVMEMINT_HEAP *psDevmemServerHeapInt;
PMR *psPMRInt;
DEVMEMINT_RESERVATION *psReservationInt = NULL;
psDevmemServerHeapInt = (DEVMEMINT_HEAP *) hDevmemServerHeap;
psPMRInt = (PMR *) hPMR;
eError =
DevmemIntReserveRangeAndMapPMR(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
psDevmemServerHeapInt,
sAddress,
uiLength, psPMRInt, uiFlags, &psReservationInt);
*phReservation = psReservationInt;
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntUnreserveRange(IMG_HANDLE hBridge, IMG_HANDLE hReservation)
{
PVRSRV_ERROR eError;
DEVMEMINT_RESERVATION *psReservationInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psReservationInt = (DEVMEMINT_RESERVATION *) hReservation;
eError = DevmemIntUnreserveRange(psReservationInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeChangeSparseMem(IMG_HANDLE hBridge,
IMG_UINT32 ui32AllocPageCount,
IMG_UINT32 *pui32AllocPageIndices,
IMG_UINT32 ui32FreePageCount,
IMG_UINT32 *pui32FreePageIndices,
IMG_UINT32 ui32SparseFlags, IMG_HANDLE hReservation)
{
PVRSRV_ERROR eError;
DEVMEMINT_RESERVATION *psReservationInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psReservationInt = (DEVMEMINT_RESERVATION *) hReservation;
eError =
DevmemIntChangeSparse(ui32AllocPageCount,
pui32AllocPageIndices,
ui32FreePageCount,
pui32FreePageIndices, ui32SparseFlags, psReservationInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIsVDevAddrValid(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemCtx,
IMG_DEV_VIRTADDR sAddress)
{
PVRSRV_ERROR eError;
DEVMEMINT_CTX *psDevmemCtxInt;
psDevmemCtxInt = (DEVMEMINT_CTX *) hDevmemCtx;
eError =
DevmemIntIsVDevAddrValid(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
psDevmemCtxInt, sAddress);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemInvalidateFBSCTable(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemCtx,
IMG_UINT64 ui64FBSCEntries)
{
#if defined(RGX_FEATURE_FBCDC)
PVRSRV_ERROR eError;
DEVMEMINT_CTX *psDevmemCtxInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psDevmemCtxInt = (DEVMEMINT_CTX *) hDevmemCtx;
eError = DevmemIntInvalidateFBSCTable(psDevmemCtxInt, ui64FBSCEntries);
return eError;
#else
PVR_UNREFERENCED_PARAMETER(hBridge);
PVR_UNREFERENCED_PARAMETER(hDevmemCtx);
PVR_UNREFERENCED_PARAMETER(ui64FBSCEntries);
return PVRSRV_ERROR_NOT_IMPLEMENTED;
#endif
}
IMG_INTERNAL PVRSRV_ERROR BridgeHeapCfgHeapConfigCount(IMG_HANDLE hBridge,
IMG_UINT32 *pui32NumHeapConfigs)
{
PVRSRV_ERROR eError;
eError =
HeapCfgHeapConfigCount(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
pui32NumHeapConfigs);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeHeapCfgHeapCount(IMG_HANDLE hBridge,
IMG_UINT32 ui32HeapConfigIndex,
IMG_UINT32 *pui32NumHeaps)
{
PVRSRV_ERROR eError;
eError =
HeapCfgHeapCount(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
ui32HeapConfigIndex, pui32NumHeaps);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeHeapCfgHeapConfigName(IMG_HANDLE hBridge,
IMG_UINT32 ui32HeapConfigIndex,
IMG_UINT32 ui32HeapConfigNameBufSz,
IMG_CHAR *puiHeapConfigName)
{
PVRSRV_ERROR eError;
eError =
HeapCfgHeapConfigName(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
ui32HeapConfigIndex, ui32HeapConfigNameBufSz, puiHeapConfigName);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeHeapCfgHeapDetails(IMG_HANDLE hBridge,
IMG_UINT32 ui32HeapConfigIndex,
IMG_UINT32 ui32HeapIndex,
IMG_UINT32 ui32HeapNameBufSz,
IMG_CHAR *puiHeapNameOut,
IMG_DEV_VIRTADDR *psDevVAddrBase,
IMG_DEVMEM_SIZE_T *puiHeapLength,
IMG_DEVMEM_SIZE_T *puiReservedRegionLength,
IMG_UINT32 *pui32Log2DataPageSizeOut,
IMG_UINT32 *pui32Log2ImportAlignmentOut)
{
PVRSRV_ERROR eError;
eError =
HeapCfgHeapDetails(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
ui32HeapConfigIndex,
ui32HeapIndex,
ui32HeapNameBufSz,
puiHeapNameOut,
psDevVAddrBase,
puiHeapLength,
puiReservedRegionLength,
pui32Log2DataPageSizeOut, pui32Log2ImportAlignmentOut);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemIntRegisterPFNotifyKM(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemCtx,
IMG_BOOL bRegister)
{
PVRSRV_ERROR eError;
DEVMEMINT_CTX *psDevmemCtxInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psDevmemCtxInt = (DEVMEMINT_CTX *) hDevmemCtx;
eError = DevmemIntRegisterPFNotifyKM(psDevmemCtxInt, bRegister);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgePhysHeapGetMemInfo(IMG_HANDLE hBridge,
IMG_UINT32 ui32PhysHeapCount,
PVRSRV_PHYS_HEAP *peaPhysHeapID,
PHYS_HEAP_MEM_STATS *pasapPhysHeapMemStats)
{
PVRSRV_ERROR eError;
eError =
PVRSRVPhysHeapGetMemInfoKM(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
ui32PhysHeapCount, peaPhysHeapID, pasapPhysHeapMemStats);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeGetDefaultPhysicalHeap(IMG_HANDLE hBridge, PVRSRV_PHYS_HEAP *peHeap)
{
PVRSRV_ERROR eError;
eError =
PVRSRVGetDefaultPhysicalHeapKM(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge), peHeap);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemGetFaultAddress(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemCtx,
IMG_DEV_VIRTADDR *psFaultAddress)
{
PVRSRV_ERROR eError;
DEVMEMINT_CTX *psDevmemCtxInt;
psDevmemCtxInt = (DEVMEMINT_CTX *) hDevmemCtx;
eError =
DevmemIntGetFaultAddress(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
psDevmemCtxInt, psFaultAddress);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgePVRSRVStatsUpdateOOMStat(IMG_HANDLE hBridge,
IMG_UINT32 ui32ui32StatType,
IMG_PID ui32pid)
{
#if defined(PVRSRV_ENABLE_PROCESS_STATS)
PVRSRV_ERROR eError;
eError =
PVRSRVStatsUpdateOOMStat(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
ui32ui32StatType, ui32pid);
return eError;
#else
PVR_UNREFERENCED_PARAMETER(ui32ui32StatType);
PVR_UNREFERENCED_PARAMETER(ui32pid);
return PVRSRV_ERROR_NOT_IMPLEMENTED;
#endif
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemXIntReserveRange(IMG_HANDLE hBridge,
IMG_HANDLE hDevmemServerHeap,
IMG_DEV_VIRTADDR sAddress,
IMG_DEVMEM_SIZE_T uiLength,
IMG_HANDLE *phReservation)
{
PVRSRV_ERROR eError;
DEVMEMINT_HEAP *psDevmemServerHeapInt;
DEVMEMXINT_RESERVATION *psReservationInt = NULL;
PVR_UNREFERENCED_PARAMETER(hBridge);
psDevmemServerHeapInt = (DEVMEMINT_HEAP *) hDevmemServerHeap;
eError =
DevmemXIntReserveRange(psDevmemServerHeapInt, sAddress, uiLength, &psReservationInt);
*phReservation = psReservationInt;
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemXIntUnreserveRange(IMG_HANDLE hBridge,
IMG_HANDLE hReservation)
{
PVRSRV_ERROR eError;
DEVMEMXINT_RESERVATION *psReservationInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psReservationInt = (DEVMEMXINT_RESERVATION *) hReservation;
eError = DevmemXIntUnreserveRange(psReservationInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemXIntMapPages(IMG_HANDLE hBridge,
IMG_HANDLE hReservation,
IMG_HANDLE hPMR,
IMG_UINT32 ui32PageCount,
IMG_UINT32 ui32PhysPageOffset,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
IMG_UINT32 ui32VirtPageOffset)
{
PVRSRV_ERROR eError;
DEVMEMXINT_RESERVATION *psReservationInt;
PMR *psPMRInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psReservationInt = (DEVMEMXINT_RESERVATION *) hReservation;
psPMRInt = (PMR *) hPMR;
eError =
DevmemXIntMapPages(psReservationInt,
psPMRInt,
ui32PageCount, ui32PhysPageOffset, uiFlags, ui32VirtPageOffset);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemXIntUnmapPages(IMG_HANDLE hBridge,
IMG_HANDLE hReservation,
IMG_UINT32 ui32VirtPageOffset,
IMG_UINT32 ui32PageCount)
{
PVRSRV_ERROR eError;
DEVMEMXINT_RESERVATION *psReservationInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psReservationInt = (DEVMEMXINT_RESERVATION *) hReservation;
eError = DevmemXIntUnmapPages(psReservationInt, ui32VirtPageOffset, ui32PageCount);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeDevmemXIntMapVRangeToBackingPage(IMG_HANDLE hBridge,
IMG_HANDLE hReservation,
IMG_UINT32 ui32PageCount,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
IMG_UINT32 ui32VirtPageOffset)
{
PVRSRV_ERROR eError;
DEVMEMXINT_RESERVATION *psReservationInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psReservationInt = (DEVMEMXINT_RESERVATION *) hReservation;
eError =
DevmemXIntMapVRangeToBackingPage(psReservationInt,
ui32PageCount, uiFlags, ui32VirtPageOffset);
return eError;
}

View File

@@ -0,0 +1,93 @@
/*******************************************************************************
@File
@Title Client bridge header for pvrtl
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Exports the client bridge functions for pvrtl
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef CLIENT_PVRTL_BRIDGE_H
#define CLIENT_PVRTL_BRIDGE_H
#include "img_defs.h"
#include "pvrsrv_error.h"
#if defined(PVR_INDIRECT_BRIDGE_CLIENTS)
#include "pvr_bridge_client.h"
#include "pvr_bridge.h"
#endif
#include "common_pvrtl_bridge.h"
IMG_INTERNAL PVRSRV_ERROR BridgeTLOpenStream(IMG_HANDLE hBridge,
const IMG_CHAR * puiName,
IMG_UINT32 ui32Mode,
IMG_HANDLE * phSD, IMG_HANDLE * phTLPMR);
IMG_INTERNAL PVRSRV_ERROR BridgeTLCloseStream(IMG_HANDLE hBridge, IMG_HANDLE hSD);
IMG_INTERNAL PVRSRV_ERROR BridgeTLAcquireData(IMG_HANDLE hBridge,
IMG_HANDLE hSD,
IMG_UINT32 * pui32ReadOffset,
IMG_UINT32 * pui32ReadLen);
IMG_INTERNAL PVRSRV_ERROR BridgeTLReleaseData(IMG_HANDLE hBridge,
IMG_HANDLE hSD,
IMG_UINT32 ui32ReadOffset, IMG_UINT32 ui32ReadLen);
IMG_INTERNAL PVRSRV_ERROR BridgeTLDiscoverStreams(IMG_HANDLE hBridge,
const IMG_CHAR * puiNamePattern,
IMG_UINT32 ui32Size,
IMG_CHAR * puiStreams,
IMG_UINT32 * pui32NumFound);
IMG_INTERNAL PVRSRV_ERROR BridgeTLReserveStream(IMG_HANDLE hBridge,
IMG_HANDLE hSD,
IMG_UINT32 * pui32BufferOffset,
IMG_UINT32 ui32Size,
IMG_UINT32 ui32SizeMin,
IMG_UINT32 * pui32Available);
IMG_INTERNAL PVRSRV_ERROR BridgeTLCommitStream(IMG_HANDLE hBridge,
IMG_HANDLE hSD, IMG_UINT32 ui32ReqSize);
IMG_INTERNAL PVRSRV_ERROR BridgeTLWriteData(IMG_HANDLE hBridge,
IMG_HANDLE hSD,
IMG_UINT32 ui32Size, IMG_BYTE * pui8Data);
#endif /* CLIENT_PVRTL_BRIDGE_H */

View File

@@ -0,0 +1,173 @@
/*******************************************************************************
@File
@Title Direct client bridge for pvrtl
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Implements the client side of the bridge for pvrtl
which is used in calls from Server context.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#include "client_pvrtl_bridge.h"
#include "img_defs.h"
#include "pvr_debug.h"
/* Module specific includes */
#include "devicemem_typedefs.h"
#include "pvrsrv_tlcommon.h"
#include "tlserver.h"
IMG_INTERNAL PVRSRV_ERROR BridgeTLOpenStream(IMG_HANDLE hBridge,
const IMG_CHAR *puiName,
IMG_UINT32 ui32Mode,
IMG_HANDLE *phSD, IMG_HANDLE *phTLPMR)
{
PVRSRV_ERROR eError;
TL_STREAM_DESC *psSDInt = NULL;
PMR *psTLPMRInt = NULL;
PVR_UNREFERENCED_PARAMETER(hBridge);
eError = TLServerOpenStreamKM(puiName, ui32Mode, &psSDInt, &psTLPMRInt);
*phSD = psSDInt;
*phTLPMR = psTLPMRInt;
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeTLCloseStream(IMG_HANDLE hBridge, IMG_HANDLE hSD)
{
PVRSRV_ERROR eError;
TL_STREAM_DESC *psSDInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psSDInt = (TL_STREAM_DESC *) hSD;
eError = TLServerCloseStreamKM(psSDInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeTLAcquireData(IMG_HANDLE hBridge,
IMG_HANDLE hSD,
IMG_UINT32 *pui32ReadOffset, IMG_UINT32 *pui32ReadLen)
{
PVRSRV_ERROR eError;
TL_STREAM_DESC *psSDInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psSDInt = (TL_STREAM_DESC *) hSD;
eError = TLServerAcquireDataKM(psSDInt, pui32ReadOffset, pui32ReadLen);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeTLReleaseData(IMG_HANDLE hBridge,
IMG_HANDLE hSD,
IMG_UINT32 ui32ReadOffset, IMG_UINT32 ui32ReadLen)
{
PVRSRV_ERROR eError;
TL_STREAM_DESC *psSDInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psSDInt = (TL_STREAM_DESC *) hSD;
eError = TLServerReleaseDataKM(psSDInt, ui32ReadOffset, ui32ReadLen);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeTLDiscoverStreams(IMG_HANDLE hBridge,
const IMG_CHAR *puiNamePattern,
IMG_UINT32 ui32Size,
IMG_CHAR *puiStreams, IMG_UINT32 *pui32NumFound)
{
PVRSRV_ERROR eError;
PVR_UNREFERENCED_PARAMETER(hBridge);
eError = TLServerDiscoverStreamsKM(puiNamePattern, ui32Size, puiStreams, pui32NumFound);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeTLReserveStream(IMG_HANDLE hBridge,
IMG_HANDLE hSD,
IMG_UINT32 *pui32BufferOffset,
IMG_UINT32 ui32Size,
IMG_UINT32 ui32SizeMin, IMG_UINT32 *pui32Available)
{
PVRSRV_ERROR eError;
TL_STREAM_DESC *psSDInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psSDInt = (TL_STREAM_DESC *) hSD;
eError =
TLServerReserveStreamKM(psSDInt,
pui32BufferOffset, ui32Size, ui32SizeMin, pui32Available);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeTLCommitStream(IMG_HANDLE hBridge,
IMG_HANDLE hSD, IMG_UINT32 ui32ReqSize)
{
PVRSRV_ERROR eError;
TL_STREAM_DESC *psSDInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psSDInt = (TL_STREAM_DESC *) hSD;
eError = TLServerCommitStreamKM(psSDInt, ui32ReqSize);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeTLWriteData(IMG_HANDLE hBridge,
IMG_HANDLE hSD, IMG_UINT32 ui32Size, IMG_BYTE *pui8Data)
{
PVRSRV_ERROR eError;
TL_STREAM_DESC *psSDInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psSDInt = (TL_STREAM_DESC *) hSD;
eError = TLServerWriteDataKM(psSDInt, ui32Size, pui8Data);
return eError;
}

View File

@@ -0,0 +1,88 @@
/*******************************************************************************
@File
@Title Client bridge header for ri
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Exports the client bridge functions for ri
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef CLIENT_RI_BRIDGE_H
#define CLIENT_RI_BRIDGE_H
#include "img_defs.h"
#include "pvrsrv_error.h"
#if defined(PVR_INDIRECT_BRIDGE_CLIENTS)
#include "pvr_bridge_client.h"
#include "pvr_bridge.h"
#endif
#include "common_ri_bridge.h"
IMG_INTERNAL PVRSRV_ERROR BridgeRIWritePMREntry(IMG_HANDLE hBridge, IMG_HANDLE hPMRHandle);
IMG_INTERNAL PVRSRV_ERROR BridgeRIWriteMEMDESCEntry(IMG_HANDLE hBridge,
IMG_HANDLE hPMRHandle,
IMG_UINT32 ui32TextBSize,
const IMG_CHAR * puiTextB,
IMG_UINT64 ui64Offset,
IMG_UINT64 ui64Size,
IMG_UINT64 ui64Flags, IMG_HANDLE * phRIHandle);
IMG_INTERNAL PVRSRV_ERROR BridgeRIWriteProcListEntry(IMG_HANDLE hBridge,
IMG_UINT32 ui32TextBSize,
const IMG_CHAR * puiTextB,
IMG_UINT64 ui64Size,
IMG_UINT64 ui64DevVAddr,
IMG_HANDLE * phRIHandle);
IMG_INTERNAL PVRSRV_ERROR BridgeRIUpdateMEMDESCAddr(IMG_HANDLE hBridge,
IMG_HANDLE hRIHandle, IMG_DEV_VIRTADDR sAddr);
IMG_INTERNAL PVRSRV_ERROR BridgeRIDeleteMEMDESCEntry(IMG_HANDLE hBridge, IMG_HANDLE hRIHandle);
IMG_INTERNAL PVRSRV_ERROR BridgeRIDumpList(IMG_HANDLE hBridge, IMG_HANDLE hPMRHandle);
IMG_INTERNAL PVRSRV_ERROR BridgeRIDumpAll(IMG_HANDLE hBridge);
IMG_INTERNAL PVRSRV_ERROR BridgeRIDumpProcess(IMG_HANDLE hBridge, IMG_PID ui32Pid);
IMG_INTERNAL PVRSRV_ERROR BridgeRIWritePMREntryWithOwner(IMG_HANDLE hBridge,
IMG_HANDLE hPMRHandle, IMG_PID ui32Owner);
#endif /* CLIENT_RI_BRIDGE_H */

View File

@@ -0,0 +1,185 @@
/*******************************************************************************
@File
@Title Direct client bridge for ri
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Implements the client side of the bridge for ri
which is used in calls from Server context.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#include "client_ri_bridge.h"
#include "img_defs.h"
#include "pvr_debug.h"
/* Module specific includes */
#include "ri_typedefs.h"
#include "ri_server.h"
IMG_INTERNAL PVRSRV_ERROR BridgeRIWritePMREntry(IMG_HANDLE hBridge, IMG_HANDLE hPMRHandle)
{
PVRSRV_ERROR eError;
PMR *psPMRHandleInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psPMRHandleInt = (PMR *) hPMRHandle;
eError = RIWritePMREntryKM(psPMRHandleInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeRIWriteMEMDESCEntry(IMG_HANDLE hBridge,
IMG_HANDLE hPMRHandle,
IMG_UINT32 ui32TextBSize,
const IMG_CHAR *puiTextB,
IMG_UINT64 ui64Offset,
IMG_UINT64 ui64Size,
IMG_UINT64 ui64Flags, IMG_HANDLE *phRIHandle)
{
PVRSRV_ERROR eError;
PMR *psPMRHandleInt;
RI_HANDLE psRIHandleInt = NULL;
psPMRHandleInt = (PMR *) hPMRHandle;
eError =
RIWriteMEMDESCEntryKM(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
psPMRHandleInt,
ui32TextBSize,
puiTextB, ui64Offset, ui64Size, ui64Flags, &psRIHandleInt);
if (eError != PVRSRV_OK)
{
return eError;
}
*phRIHandle = psRIHandleInt;
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeRIWriteProcListEntry(IMG_HANDLE hBridge,
IMG_UINT32 ui32TextBSize,
const IMG_CHAR *puiTextB,
IMG_UINT64 ui64Size,
IMG_UINT64 ui64DevVAddr,
IMG_HANDLE *phRIHandle)
{
PVRSRV_ERROR eError;
RI_HANDLE psRIHandleInt = NULL;
eError =
RIWriteProcListEntryKM(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
ui32TextBSize, puiTextB, ui64Size, ui64DevVAddr, &psRIHandleInt);
*phRIHandle = psRIHandleInt;
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeRIUpdateMEMDESCAddr(IMG_HANDLE hBridge,
IMG_HANDLE hRIHandle, IMG_DEV_VIRTADDR sAddr)
{
PVRSRV_ERROR eError;
RI_HANDLE psRIHandleInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psRIHandleInt = (RI_HANDLE) hRIHandle;
eError = RIUpdateMEMDESCAddrKM(psRIHandleInt, sAddr);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeRIDeleteMEMDESCEntry(IMG_HANDLE hBridge, IMG_HANDLE hRIHandle)
{
PVRSRV_ERROR eError;
RI_HANDLE psRIHandleInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psRIHandleInt = (RI_HANDLE) hRIHandle;
eError = RIDeleteMEMDESCEntryKM(psRIHandleInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeRIDumpList(IMG_HANDLE hBridge, IMG_HANDLE hPMRHandle)
{
PVRSRV_ERROR eError;
PMR *psPMRHandleInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psPMRHandleInt = (PMR *) hPMRHandle;
eError = RIDumpListKM(psPMRHandleInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeRIDumpAll(IMG_HANDLE hBridge)
{
PVRSRV_ERROR eError;
PVR_UNREFERENCED_PARAMETER(hBridge);
eError = RIDumpAllKM();
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeRIDumpProcess(IMG_HANDLE hBridge, IMG_PID ui32Pid)
{
PVRSRV_ERROR eError;
PVR_UNREFERENCED_PARAMETER(hBridge);
eError = RIDumpProcessKM(ui32Pid);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeRIWritePMREntryWithOwner(IMG_HANDLE hBridge,
IMG_HANDLE hPMRHandle, IMG_PID ui32Owner)
{
PVRSRV_ERROR eError;
PMR *psPMRHandleInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psPMRHandleInt = (PMR *) hPMRHandle;
eError = RIWritePMREntryWithOwnerKM(psPMRHandleInt, ui32Owner);
return eError;
}

View File

@@ -0,0 +1,102 @@
/*******************************************************************************
@File
@Title Client bridge header for sync
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Exports the client bridge functions for sync
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef CLIENT_SYNC_BRIDGE_H
#define CLIENT_SYNC_BRIDGE_H
#include "img_defs.h"
#include "pvrsrv_error.h"
#if defined(PVR_INDIRECT_BRIDGE_CLIENTS)
#include "pvr_bridge_client.h"
#include "pvr_bridge.h"
#endif
#include "common_sync_bridge.h"
IMG_INTERNAL PVRSRV_ERROR BridgeAllocSyncPrimitiveBlock(IMG_HANDLE hBridge,
IMG_HANDLE * phSyncHandle,
IMG_UINT32 * pui32SyncPrimVAddr,
IMG_UINT32 * pui32SyncPrimBlockSize,
IMG_HANDLE * phhSyncPMR);
IMG_INTERNAL PVRSRV_ERROR BridgeFreeSyncPrimitiveBlock(IMG_HANDLE hBridge, IMG_HANDLE hSyncHandle);
IMG_INTERNAL PVRSRV_ERROR BridgeSyncPrimSet(IMG_HANDLE hBridge,
IMG_HANDLE hSyncHandle,
IMG_UINT32 ui32Index, IMG_UINT32 ui32Value);
IMG_INTERNAL PVRSRV_ERROR BridgeSyncPrimPDump(IMG_HANDLE hBridge,
IMG_HANDLE hSyncHandle, IMG_UINT32 ui32Offset);
IMG_INTERNAL PVRSRV_ERROR BridgeSyncPrimPDumpValue(IMG_HANDLE hBridge,
IMG_HANDLE hSyncHandle,
IMG_UINT32 ui32Offset, IMG_UINT32 ui32Value);
IMG_INTERNAL PVRSRV_ERROR BridgeSyncPrimPDumpPol(IMG_HANDLE hBridge,
IMG_HANDLE hSyncHandle,
IMG_UINT32 ui32Offset,
IMG_UINT32 ui32Value,
IMG_UINT32 ui32Mask,
PDUMP_POLL_OPERATOR eOperator,
PDUMP_FLAGS_T uiPDumpFlags);
IMG_INTERNAL PVRSRV_ERROR BridgeSyncPrimPDumpCBP(IMG_HANDLE hBridge,
IMG_HANDLE hSyncHandle,
IMG_UINT32 ui32Offset,
IMG_DEVMEM_OFFSET_T uiWriteOffset,
IMG_DEVMEM_SIZE_T uiPacketSize,
IMG_DEVMEM_SIZE_T uiBufferSize);
IMG_INTERNAL PVRSRV_ERROR BridgeSyncAllocEvent(IMG_HANDLE hBridge,
IMG_BOOL bServerSync,
IMG_UINT32 ui32FWAddr,
IMG_UINT32 ui32ClassNameSize,
const IMG_CHAR * puiClassName);
IMG_INTERNAL PVRSRV_ERROR BridgeSyncFreeEvent(IMG_HANDLE hBridge, IMG_UINT32 ui32FWAddr);
IMG_INTERNAL PVRSRV_ERROR BridgeSyncCheckpointSignalledPDumpPol(IMG_HANDLE hBridge,
PVRSRV_FENCE hFence);
#endif /* CLIENT_SYNC_BRIDGE_H */

View File

@@ -0,0 +1,262 @@
/*******************************************************************************
@File
@Title Direct client bridge for sync
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Implements the client side of the bridge for sync
which is used in calls from Server context.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#include "client_sync_bridge.h"
#include "img_defs.h"
#include "pvr_debug.h"
/* Module specific includes */
#include "pdump.h"
#include "pdumpdefs.h"
#include "devicemem_typedefs.h"
#include "pvrsrv_sync_km.h"
#include <powervr/pvrsrv_sync_ext.h>
#include "sync.h"
#include "sync_server.h"
#include "pdump.h"
#include "pvrsrv_sync_km.h"
#include "sync_fallback_server.h"
#include "sync_checkpoint.h"
IMG_INTERNAL PVRSRV_ERROR BridgeAllocSyncPrimitiveBlock(IMG_HANDLE hBridge,
IMG_HANDLE *phSyncHandle,
IMG_UINT32 *pui32SyncPrimVAddr,
IMG_UINT32 *pui32SyncPrimBlockSize,
IMG_HANDLE *phhSyncPMR)
{
PVRSRV_ERROR eError;
SYNC_PRIMITIVE_BLOCK *psSyncHandleInt = NULL;
PMR *pshSyncPMRInt = NULL;
eError =
PVRSRVAllocSyncPrimitiveBlockKM(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
&psSyncHandleInt,
pui32SyncPrimVAddr,
pui32SyncPrimBlockSize, &pshSyncPMRInt);
*phSyncHandle = psSyncHandleInt;
*phhSyncPMR = pshSyncPMRInt;
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeFreeSyncPrimitiveBlock(IMG_HANDLE hBridge, IMG_HANDLE hSyncHandle)
{
PVRSRV_ERROR eError;
SYNC_PRIMITIVE_BLOCK *psSyncHandleInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psSyncHandleInt = (SYNC_PRIMITIVE_BLOCK *) hSyncHandle;
eError = PVRSRVFreeSyncPrimitiveBlockKM(psSyncHandleInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeSyncPrimSet(IMG_HANDLE hBridge,
IMG_HANDLE hSyncHandle,
IMG_UINT32 ui32Index, IMG_UINT32 ui32Value)
{
PVRSRV_ERROR eError;
SYNC_PRIMITIVE_BLOCK *psSyncHandleInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psSyncHandleInt = (SYNC_PRIMITIVE_BLOCK *) hSyncHandle;
eError = PVRSRVSyncPrimSetKM(psSyncHandleInt, ui32Index, ui32Value);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeSyncPrimPDump(IMG_HANDLE hBridge,
IMG_HANDLE hSyncHandle, IMG_UINT32 ui32Offset)
{
#if defined(PDUMP)
PVRSRV_ERROR eError;
SYNC_PRIMITIVE_BLOCK *psSyncHandleInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psSyncHandleInt = (SYNC_PRIMITIVE_BLOCK *) hSyncHandle;
eError = PVRSRVSyncPrimPDumpKM(psSyncHandleInt, ui32Offset);
return eError;
#else
PVR_UNREFERENCED_PARAMETER(hBridge);
PVR_UNREFERENCED_PARAMETER(hSyncHandle);
PVR_UNREFERENCED_PARAMETER(ui32Offset);
return PVRSRV_ERROR_NOT_IMPLEMENTED;
#endif
}
IMG_INTERNAL PVRSRV_ERROR BridgeSyncPrimPDumpValue(IMG_HANDLE hBridge,
IMG_HANDLE hSyncHandle,
IMG_UINT32 ui32Offset, IMG_UINT32 ui32Value)
{
#if defined(PDUMP)
PVRSRV_ERROR eError;
SYNC_PRIMITIVE_BLOCK *psSyncHandleInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psSyncHandleInt = (SYNC_PRIMITIVE_BLOCK *) hSyncHandle;
eError = PVRSRVSyncPrimPDumpValueKM(psSyncHandleInt, ui32Offset, ui32Value);
return eError;
#else
PVR_UNREFERENCED_PARAMETER(hBridge);
PVR_UNREFERENCED_PARAMETER(hSyncHandle);
PVR_UNREFERENCED_PARAMETER(ui32Offset);
PVR_UNREFERENCED_PARAMETER(ui32Value);
return PVRSRV_ERROR_NOT_IMPLEMENTED;
#endif
}
IMG_INTERNAL PVRSRV_ERROR BridgeSyncPrimPDumpPol(IMG_HANDLE hBridge,
IMG_HANDLE hSyncHandle,
IMG_UINT32 ui32Offset,
IMG_UINT32 ui32Value,
IMG_UINT32 ui32Mask,
PDUMP_POLL_OPERATOR eOperator,
PDUMP_FLAGS_T uiPDumpFlags)
{
#if defined(PDUMP)
PVRSRV_ERROR eError;
SYNC_PRIMITIVE_BLOCK *psSyncHandleInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psSyncHandleInt = (SYNC_PRIMITIVE_BLOCK *) hSyncHandle;
eError =
PVRSRVSyncPrimPDumpPolKM(psSyncHandleInt,
ui32Offset, ui32Value, ui32Mask, eOperator, uiPDumpFlags);
return eError;
#else
PVR_UNREFERENCED_PARAMETER(hBridge);
PVR_UNREFERENCED_PARAMETER(hSyncHandle);
PVR_UNREFERENCED_PARAMETER(ui32Offset);
PVR_UNREFERENCED_PARAMETER(ui32Value);
PVR_UNREFERENCED_PARAMETER(ui32Mask);
PVR_UNREFERENCED_PARAMETER(eOperator);
PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
return PVRSRV_ERROR_NOT_IMPLEMENTED;
#endif
}
IMG_INTERNAL PVRSRV_ERROR BridgeSyncPrimPDumpCBP(IMG_HANDLE hBridge,
IMG_HANDLE hSyncHandle,
IMG_UINT32 ui32Offset,
IMG_DEVMEM_OFFSET_T uiWriteOffset,
IMG_DEVMEM_SIZE_T uiPacketSize,
IMG_DEVMEM_SIZE_T uiBufferSize)
{
#if defined(PDUMP)
PVRSRV_ERROR eError;
SYNC_PRIMITIVE_BLOCK *psSyncHandleInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
psSyncHandleInt = (SYNC_PRIMITIVE_BLOCK *) hSyncHandle;
eError =
PVRSRVSyncPrimPDumpCBPKM(psSyncHandleInt,
ui32Offset, uiWriteOffset, uiPacketSize, uiBufferSize);
return eError;
#else
PVR_UNREFERENCED_PARAMETER(hBridge);
PVR_UNREFERENCED_PARAMETER(hSyncHandle);
PVR_UNREFERENCED_PARAMETER(ui32Offset);
PVR_UNREFERENCED_PARAMETER(uiWriteOffset);
PVR_UNREFERENCED_PARAMETER(uiPacketSize);
PVR_UNREFERENCED_PARAMETER(uiBufferSize);
return PVRSRV_ERROR_NOT_IMPLEMENTED;
#endif
}
IMG_INTERNAL PVRSRV_ERROR BridgeSyncAllocEvent(IMG_HANDLE hBridge,
IMG_BOOL bServerSync,
IMG_UINT32 ui32FWAddr,
IMG_UINT32 ui32ClassNameSize,
const IMG_CHAR *puiClassName)
{
PVRSRV_ERROR eError;
eError =
PVRSRVSyncAllocEventKM(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
bServerSync, ui32FWAddr, ui32ClassNameSize, puiClassName);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeSyncFreeEvent(IMG_HANDLE hBridge, IMG_UINT32 ui32FWAddr)
{
PVRSRV_ERROR eError;
eError = PVRSRVSyncFreeEventKM(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge), ui32FWAddr);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeSyncCheckpointSignalledPDumpPol(IMG_HANDLE hBridge,
PVRSRV_FENCE hFence)
{
#if defined(PDUMP)
PVRSRV_ERROR eError;
PVR_UNREFERENCED_PARAMETER(hBridge);
eError = PVRSRVSyncCheckpointSignalledPDumpPolKM(hFence);
return eError;
#else
PVR_UNREFERENCED_PARAMETER(hBridge);
PVR_UNREFERENCED_PARAMETER(hFence);
return PVRSRV_ERROR_NOT_IMPLEMENTED;
#endif
}

View File

@@ -0,0 +1,68 @@
/*******************************************************************************
@File
@Title Client bridge header for synctracking
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Exports the client bridge functions for synctracking
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef CLIENT_SYNCTRACKING_BRIDGE_H
#define CLIENT_SYNCTRACKING_BRIDGE_H
#include "img_defs.h"
#include "pvrsrv_error.h"
#if defined(PVR_INDIRECT_BRIDGE_CLIENTS)
#include "pvr_bridge_client.h"
#include "pvr_bridge.h"
#endif
#include "common_synctracking_bridge.h"
IMG_INTERNAL PVRSRV_ERROR BridgeSyncRecordRemoveByHandle(IMG_HANDLE hBridge, IMG_HANDLE hhRecord);
IMG_INTERNAL PVRSRV_ERROR BridgeSyncRecordAdd(IMG_HANDLE hBridge,
IMG_HANDLE * phhRecord,
IMG_HANDLE hhServerSyncPrimBlock,
IMG_UINT32 ui32ui32FwBlockAddr,
IMG_UINT32 ui32ui32SyncOffset,
IMG_BOOL bbServerSync,
IMG_UINT32 ui32ClassNameSize,
const IMG_CHAR * puiClassName);
#endif /* CLIENT_SYNCTRACKING_BRIDGE_H */

View File

@@ -0,0 +1,92 @@
/*******************************************************************************
@File
@Title Direct client bridge for synctracking
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Implements the client side of the bridge for synctracking
which is used in calls from Server context.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#include "client_synctracking_bridge.h"
#include "img_defs.h"
#include "pvr_debug.h"
/* Module specific includes */
#include "sync.h"
#include "sync_server.h"
IMG_INTERNAL PVRSRV_ERROR BridgeSyncRecordRemoveByHandle(IMG_HANDLE hBridge, IMG_HANDLE hhRecord)
{
PVRSRV_ERROR eError;
SYNC_RECORD_HANDLE pshRecordInt;
PVR_UNREFERENCED_PARAMETER(hBridge);
pshRecordInt = (SYNC_RECORD_HANDLE) hhRecord;
eError = PVRSRVSyncRecordRemoveByHandleKM(pshRecordInt);
return eError;
}
IMG_INTERNAL PVRSRV_ERROR BridgeSyncRecordAdd(IMG_HANDLE hBridge,
IMG_HANDLE *phhRecord,
IMG_HANDLE hhServerSyncPrimBlock,
IMG_UINT32 ui32ui32FwBlockAddr,
IMG_UINT32 ui32ui32SyncOffset,
IMG_BOOL bbServerSync,
IMG_UINT32 ui32ClassNameSize,
const IMG_CHAR *puiClassName)
{
PVRSRV_ERROR eError;
SYNC_RECORD_HANDLE pshRecordInt = NULL;
SYNC_PRIMITIVE_BLOCK *pshServerSyncPrimBlockInt;
pshServerSyncPrimBlockInt = (SYNC_PRIMITIVE_BLOCK *) hhServerSyncPrimBlock;
eError =
PVRSRVSyncRecordAddKM(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
&pshRecordInt,
pshServerSyncPrimBlockInt,
ui32ui32FwBlockAddr,
ui32ui32SyncOffset,
bbServerSync, ui32ClassNameSize, puiClassName);
*phhRecord = pshRecordInt;
return eError;
}

View File

@@ -0,0 +1,126 @@
/*******************************************************************************
@File
@Title Common bridge header for cache
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for cache
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_CACHE_BRIDGE_H
#define COMMON_CACHE_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "cache_ops.h"
#define PVRSRV_BRIDGE_CACHE_CMD_FIRST 0
#define PVRSRV_BRIDGE_CACHE_CACHEOPQUEUE PVRSRV_BRIDGE_CACHE_CMD_FIRST+0
#define PVRSRV_BRIDGE_CACHE_CACHEOPEXEC PVRSRV_BRIDGE_CACHE_CMD_FIRST+1
#define PVRSRV_BRIDGE_CACHE_CACHEOPLOG PVRSRV_BRIDGE_CACHE_CMD_FIRST+2
#define PVRSRV_BRIDGE_CACHE_CMD_LAST (PVRSRV_BRIDGE_CACHE_CMD_FIRST+2)
/*******************************************
CacheOpQueue
*******************************************/
/* Bridge in structure for CacheOpQueue */
typedef struct PVRSRV_BRIDGE_IN_CACHEOPQUEUE_TAG
{
PVRSRV_CACHE_OP *piuCacheOp;
IMG_UINT64 *pui64Address;
IMG_DEVMEM_OFFSET_T *puiOffset;
IMG_DEVMEM_SIZE_T *puiSize;
IMG_HANDLE *phPMR;
IMG_UINT32 ui32NumCacheOps;
IMG_UINT32 ui32OpTimeline;
} __packed PVRSRV_BRIDGE_IN_CACHEOPQUEUE;
/* Bridge out structure for CacheOpQueue */
typedef struct PVRSRV_BRIDGE_OUT_CACHEOPQUEUE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_CACHEOPQUEUE;
/*******************************************
CacheOpExec
*******************************************/
/* Bridge in structure for CacheOpExec */
typedef struct PVRSRV_BRIDGE_IN_CACHEOPEXEC_TAG
{
IMG_UINT64 ui64Address;
IMG_DEVMEM_OFFSET_T uiOffset;
IMG_DEVMEM_SIZE_T uiSize;
IMG_HANDLE hPMR;
PVRSRV_CACHE_OP iuCacheOp;
} __packed PVRSRV_BRIDGE_IN_CACHEOPEXEC;
/* Bridge out structure for CacheOpExec */
typedef struct PVRSRV_BRIDGE_OUT_CACHEOPEXEC_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_CACHEOPEXEC;
/*******************************************
CacheOpLog
*******************************************/
/* Bridge in structure for CacheOpLog */
typedef struct PVRSRV_BRIDGE_IN_CACHEOPLOG_TAG
{
IMG_INT64 i64EndTime;
IMG_INT64 i64StartTime;
IMG_UINT64 ui64Address;
IMG_DEVMEM_OFFSET_T uiOffset;
IMG_DEVMEM_SIZE_T uiSize;
IMG_HANDLE hPMR;
PVRSRV_CACHE_OP iuCacheOp;
} __packed PVRSRV_BRIDGE_IN_CACHEOPLOG;
/* Bridge out structure for CacheOpLog */
typedef struct PVRSRV_BRIDGE_OUT_CACHEOPLOG_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_CACHEOPLOG;
#endif /* COMMON_CACHE_BRIDGE_H */

View File

@@ -0,0 +1,114 @@
/*******************************************************************************
@File
@Title Common bridge header for cmm
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for cmm
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_CMM_BRIDGE_H
#define COMMON_CMM_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "devicemem_typedefs.h"
#define PVRSRV_BRIDGE_CMM_CMD_FIRST 0
#define PVRSRV_BRIDGE_CMM_DEVMEMINTEXPORTCTX PVRSRV_BRIDGE_CMM_CMD_FIRST+0
#define PVRSRV_BRIDGE_CMM_DEVMEMINTUNEXPORTCTX PVRSRV_BRIDGE_CMM_CMD_FIRST+1
#define PVRSRV_BRIDGE_CMM_DEVMEMINTACQUIREREMOTECTX PVRSRV_BRIDGE_CMM_CMD_FIRST+2
#define PVRSRV_BRIDGE_CMM_CMD_LAST (PVRSRV_BRIDGE_CMM_CMD_FIRST+2)
/*******************************************
DevmemIntExportCtx
*******************************************/
/* Bridge in structure for DevmemIntExportCtx */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINTEXPORTCTX_TAG
{
IMG_HANDLE hContext;
IMG_HANDLE hPMR;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINTEXPORTCTX;
/* Bridge out structure for DevmemIntExportCtx */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINTEXPORTCTX_TAG
{
IMG_HANDLE hContextExport;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINTEXPORTCTX;
/*******************************************
DevmemIntUnexportCtx
*******************************************/
/* Bridge in structure for DevmemIntUnexportCtx */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINTUNEXPORTCTX_TAG
{
IMG_HANDLE hContextExport;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINTUNEXPORTCTX;
/* Bridge out structure for DevmemIntUnexportCtx */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINTUNEXPORTCTX_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINTUNEXPORTCTX;
/*******************************************
DevmemIntAcquireRemoteCtx
*******************************************/
/* Bridge in structure for DevmemIntAcquireRemoteCtx */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINTACQUIREREMOTECTX_TAG
{
IMG_HANDLE hPMR;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINTACQUIREREMOTECTX;
/* Bridge out structure for DevmemIntAcquireRemoteCtx */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINTACQUIREREMOTECTX_TAG
{
IMG_HANDLE hContext;
IMG_HANDLE hPrivData;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINTACQUIREREMOTECTX;
#endif /* COMMON_CMM_BRIDGE_H */

View File

@@ -0,0 +1,185 @@
/*******************************************************************************
@File
@Title Common bridge header for devicememhistory
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for devicememhistory
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_DEVICEMEMHISTORY_BRIDGE_H
#define COMMON_DEVICEMEMHISTORY_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "img_types.h"
#include "img_defs.h"
#include "devicemem_typedefs.h"
#define PVRSRV_BRIDGE_DEVICEMEMHISTORY_CMD_FIRST 0
#define PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYMAP PVRSRV_BRIDGE_DEVICEMEMHISTORY_CMD_FIRST+0
#define PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYUNMAP PVRSRV_BRIDGE_DEVICEMEMHISTORY_CMD_FIRST+1
#define PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYMAPVRANGE PVRSRV_BRIDGE_DEVICEMEMHISTORY_CMD_FIRST+2
#define PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYUNMAPVRANGE PVRSRV_BRIDGE_DEVICEMEMHISTORY_CMD_FIRST+3
#define PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYSPARSECHANGE PVRSRV_BRIDGE_DEVICEMEMHISTORY_CMD_FIRST+4
#define PVRSRV_BRIDGE_DEVICEMEMHISTORY_CMD_LAST (PVRSRV_BRIDGE_DEVICEMEMHISTORY_CMD_FIRST+4)
/*******************************************
DevicememHistoryMap
*******************************************/
/* Bridge in structure for DevicememHistoryMap */
typedef struct PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYMAP_TAG
{
IMG_DEV_VIRTADDR sDevVAddr;
IMG_DEVMEM_SIZE_T uiOffset;
IMG_DEVMEM_SIZE_T uiSize;
IMG_HANDLE hPMR;
const IMG_CHAR *puiText;
IMG_UINT32 ui32AllocationIndex;
IMG_UINT32 ui32Log2PageSize;
} __packed PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYMAP;
/* Bridge out structure for DevicememHistoryMap */
typedef struct PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYMAP_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32AllocationIndexOut;
} __packed PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYMAP;
/*******************************************
DevicememHistoryUnmap
*******************************************/
/* Bridge in structure for DevicememHistoryUnmap */
typedef struct PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYUNMAP_TAG
{
IMG_DEV_VIRTADDR sDevVAddr;
IMG_DEVMEM_SIZE_T uiOffset;
IMG_DEVMEM_SIZE_T uiSize;
IMG_HANDLE hPMR;
const IMG_CHAR *puiText;
IMG_UINT32 ui32AllocationIndex;
IMG_UINT32 ui32Log2PageSize;
} __packed PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYUNMAP;
/* Bridge out structure for DevicememHistoryUnmap */
typedef struct PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYUNMAP_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32AllocationIndexOut;
} __packed PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYUNMAP;
/*******************************************
DevicememHistoryMapVRange
*******************************************/
/* Bridge in structure for DevicememHistoryMapVRange */
typedef struct PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYMAPVRANGE_TAG
{
IMG_DEV_VIRTADDR sBaseDevVAddr;
IMG_DEVMEM_SIZE_T uiAllocSize;
const IMG_CHAR *puiText;
IMG_UINT32 ui32AllocationIndex;
IMG_UINT32 ui32Log2PageSize;
IMG_UINT32 ui32NumPages;
IMG_UINT32 ui32ui32StartPage;
} __packed PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYMAPVRANGE;
/* Bridge out structure for DevicememHistoryMapVRange */
typedef struct PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYMAPVRANGE_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32AllocationIndexOut;
} __packed PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYMAPVRANGE;
/*******************************************
DevicememHistoryUnmapVRange
*******************************************/
/* Bridge in structure for DevicememHistoryUnmapVRange */
typedef struct PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYUNMAPVRANGE_TAG
{
IMG_DEV_VIRTADDR sBaseDevVAddr;
IMG_DEVMEM_SIZE_T uiAllocSize;
const IMG_CHAR *puiText;
IMG_UINT32 ui32AllocationIndex;
IMG_UINT32 ui32Log2PageSize;
IMG_UINT32 ui32NumPages;
IMG_UINT32 ui32ui32StartPage;
} __packed PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYUNMAPVRANGE;
/* Bridge out structure for DevicememHistoryUnmapVRange */
typedef struct PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYUNMAPVRANGE_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32AllocationIndexOut;
} __packed PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYUNMAPVRANGE;
/*******************************************
DevicememHistorySparseChange
*******************************************/
/* Bridge in structure for DevicememHistorySparseChange */
typedef struct PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYSPARSECHANGE_TAG
{
IMG_DEV_VIRTADDR sDevVAddr;
IMG_DEVMEM_SIZE_T uiOffset;
IMG_DEVMEM_SIZE_T uiSize;
IMG_HANDLE hPMR;
IMG_UINT32 *pui32AllocPageIndices;
IMG_UINT32 *pui32FreePageIndices;
const IMG_CHAR *puiText;
IMG_UINT32 ui32AllocPageCount;
IMG_UINT32 ui32AllocationIndex;
IMG_UINT32 ui32FreePageCount;
IMG_UINT32 ui32Log2PageSize;
} __packed PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYSPARSECHANGE;
/* Bridge out structure for DevicememHistorySparseChange */
typedef struct PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYSPARSECHANGE_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32AllocationIndexOut;
} __packed PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYSPARSECHANGE;
#endif /* COMMON_DEVICEMEMHISTORY_BRIDGE_H */

View File

@@ -0,0 +1,153 @@
/*******************************************************************************
@File
@Title Common bridge header for di
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for di
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_DI_BRIDGE_H
#define COMMON_DI_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "pvrsrv_tlcommon.h"
#include "pvr_dicommon.h"
#define PVRSRV_BRIDGE_DI_CMD_FIRST 0
#define PVRSRV_BRIDGE_DI_DICREATECONTEXT PVRSRV_BRIDGE_DI_CMD_FIRST+0
#define PVRSRV_BRIDGE_DI_DIDESTROYCONTEXT PVRSRV_BRIDGE_DI_CMD_FIRST+1
#define PVRSRV_BRIDGE_DI_DIREADENTRY PVRSRV_BRIDGE_DI_CMD_FIRST+2
#define PVRSRV_BRIDGE_DI_DIWRITEENTRY PVRSRV_BRIDGE_DI_CMD_FIRST+3
#define PVRSRV_BRIDGE_DI_DILISTALLENTRIES PVRSRV_BRIDGE_DI_CMD_FIRST+4
#define PVRSRV_BRIDGE_DI_CMD_LAST (PVRSRV_BRIDGE_DI_CMD_FIRST+4)
/*******************************************
DICreateContext
*******************************************/
/* Bridge in structure for DICreateContext */
typedef struct PVRSRV_BRIDGE_IN_DICREATECONTEXT_TAG
{
IMG_CHAR *puiStreamName;
} __packed PVRSRV_BRIDGE_IN_DICREATECONTEXT;
/* Bridge out structure for DICreateContext */
typedef struct PVRSRV_BRIDGE_OUT_DICREATECONTEXT_TAG
{
IMG_HANDLE hContext;
IMG_CHAR *puiStreamName;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DICREATECONTEXT;
/*******************************************
DIDestroyContext
*******************************************/
/* Bridge in structure for DIDestroyContext */
typedef struct PVRSRV_BRIDGE_IN_DIDESTROYCONTEXT_TAG
{
IMG_HANDLE hContext;
} __packed PVRSRV_BRIDGE_IN_DIDESTROYCONTEXT;
/* Bridge out structure for DIDestroyContext */
typedef struct PVRSRV_BRIDGE_OUT_DIDESTROYCONTEXT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DIDESTROYCONTEXT;
/*******************************************
DIReadEntry
*******************************************/
/* Bridge in structure for DIReadEntry */
typedef struct PVRSRV_BRIDGE_IN_DIREADENTRY_TAG
{
IMG_UINT64 ui64Offset;
IMG_UINT64 ui64Size;
IMG_HANDLE hContext;
const IMG_CHAR *puiEntryPath;
} __packed PVRSRV_BRIDGE_IN_DIREADENTRY;
/* Bridge out structure for DIReadEntry */
typedef struct PVRSRV_BRIDGE_OUT_DIREADENTRY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DIREADENTRY;
/*******************************************
DIWriteEntry
*******************************************/
/* Bridge in structure for DIWriteEntry */
typedef struct PVRSRV_BRIDGE_IN_DIWRITEENTRY_TAG
{
IMG_HANDLE hContext;
const IMG_CHAR *puiEntryPath;
const IMG_CHAR *puiValue;
IMG_UINT32 ui32ValueSize;
} __packed PVRSRV_BRIDGE_IN_DIWRITEENTRY;
/* Bridge out structure for DIWriteEntry */
typedef struct PVRSRV_BRIDGE_OUT_DIWRITEENTRY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DIWRITEENTRY;
/*******************************************
DIListAllEntries
*******************************************/
/* Bridge in structure for DIListAllEntries */
typedef struct PVRSRV_BRIDGE_IN_DILISTALLENTRIES_TAG
{
IMG_HANDLE hContext;
} __packed PVRSRV_BRIDGE_IN_DILISTALLENTRIES;
/* Bridge out structure for DIListAllEntries */
typedef struct PVRSRV_BRIDGE_OUT_DILISTALLENTRIES_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DILISTALLENTRIES;
#endif /* COMMON_DI_BRIDGE_H */

View File

@@ -0,0 +1,145 @@
/*******************************************************************************
@File
@Title Common bridge header for dmabuf
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for dmabuf
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_DMABUF_BRIDGE_H
#define COMMON_DMABUF_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "pvrsrv_memallocflags.h"
#define PVRSRV_BRIDGE_DMABUF_CMD_FIRST 0
#define PVRSRV_BRIDGE_DMABUF_PHYSMEMIMPORTDMABUF PVRSRV_BRIDGE_DMABUF_CMD_FIRST+0
#define PVRSRV_BRIDGE_DMABUF_PHYSMEMEXPORTDMABUF PVRSRV_BRIDGE_DMABUF_CMD_FIRST+1
#define PVRSRV_BRIDGE_DMABUF_PHYSMEMEXPORTGEMHANDLE PVRSRV_BRIDGE_DMABUF_CMD_FIRST+2
#define PVRSRV_BRIDGE_DMABUF_PHYSMEMIMPORTSPARSEDMABUF PVRSRV_BRIDGE_DMABUF_CMD_FIRST+3
#define PVRSRV_BRIDGE_DMABUF_CMD_LAST (PVRSRV_BRIDGE_DMABUF_CMD_FIRST+3)
/*******************************************
PhysmemImportDmaBuf
*******************************************/
/* Bridge in structure for PhysmemImportDmaBuf */
typedef struct PVRSRV_BRIDGE_IN_PHYSMEMIMPORTDMABUF_TAG
{
const IMG_CHAR *puiName;
IMG_INT ifd;
IMG_UINT32 ui32NameSize;
PVRSRV_MEMALLOCFLAGS_T uiFlags;
} __packed PVRSRV_BRIDGE_IN_PHYSMEMIMPORTDMABUF;
/* Bridge out structure for PhysmemImportDmaBuf */
typedef struct PVRSRV_BRIDGE_OUT_PHYSMEMIMPORTDMABUF_TAG
{
IMG_DEVMEM_ALIGN_T uiAlign;
IMG_DEVMEM_SIZE_T uiSize;
IMG_HANDLE hPMRPtr;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_PHYSMEMIMPORTDMABUF;
/*******************************************
PhysmemExportDmaBuf
*******************************************/
/* Bridge in structure for PhysmemExportDmaBuf */
typedef struct PVRSRV_BRIDGE_IN_PHYSMEMEXPORTDMABUF_TAG
{
IMG_HANDLE hPMR;
} __packed PVRSRV_BRIDGE_IN_PHYSMEMEXPORTDMABUF;
/* Bridge out structure for PhysmemExportDmaBuf */
typedef struct PVRSRV_BRIDGE_OUT_PHYSMEMEXPORTDMABUF_TAG
{
PVRSRV_ERROR eError;
IMG_INT iFd;
} __packed PVRSRV_BRIDGE_OUT_PHYSMEMEXPORTDMABUF;
/*******************************************
PhysmemExportGemHandle
*******************************************/
/* Bridge in structure for PhysmemExportGemHandle */
typedef struct PVRSRV_BRIDGE_IN_PHYSMEMEXPORTGEMHANDLE_TAG
{
IMG_HANDLE hPMR;
} __packed PVRSRV_BRIDGE_IN_PHYSMEMEXPORTGEMHANDLE;
/* Bridge out structure for PhysmemExportGemHandle */
typedef struct PVRSRV_BRIDGE_OUT_PHYSMEMEXPORTGEMHANDLE_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32Handle;
} __packed PVRSRV_BRIDGE_OUT_PHYSMEMEXPORTGEMHANDLE;
/*******************************************
PhysmemImportSparseDmaBuf
*******************************************/
/* Bridge in structure for PhysmemImportSparseDmaBuf */
typedef struct PVRSRV_BRIDGE_IN_PHYSMEMIMPORTSPARSEDMABUF_TAG
{
IMG_DEVMEM_SIZE_T uiChunkSize;
IMG_UINT32 *pui32MappingTable;
const IMG_CHAR *puiName;
IMG_INT ifd;
IMG_UINT32 ui32NameSize;
IMG_UINT32 ui32NumPhysChunks;
IMG_UINT32 ui32NumVirtChunks;
PVRSRV_MEMALLOCFLAGS_T uiFlags;
} __packed PVRSRV_BRIDGE_IN_PHYSMEMIMPORTSPARSEDMABUF;
/* Bridge out structure for PhysmemImportSparseDmaBuf */
typedef struct PVRSRV_BRIDGE_OUT_PHYSMEMIMPORTSPARSEDMABUF_TAG
{
IMG_DEVMEM_ALIGN_T uiAlign;
IMG_DEVMEM_SIZE_T uiSize;
IMG_HANDLE hPMRPtr;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_PHYSMEMIMPORTSPARSEDMABUF;
#endif /* COMMON_DMABUF_BRIDGE_H */

View File

@@ -0,0 +1,82 @@
/*******************************************************************************
@File
@Title Common bridge header for htbuffer
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for htbuffer
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_HTBUFFER_BRIDGE_H
#define COMMON_HTBUFFER_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "devicemem_typedefs.h"
#include "htbuffer_types.h"
#define PVRSRV_BRIDGE_HTBUFFER_CMD_FIRST 0
#define PVRSRV_BRIDGE_HTBUFFER_HTBCONTROL PVRSRV_BRIDGE_HTBUFFER_CMD_FIRST+0
#define PVRSRV_BRIDGE_HTBUFFER_CMD_LAST (PVRSRV_BRIDGE_HTBUFFER_CMD_FIRST+0)
/*******************************************
HTBControl
*******************************************/
/* Bridge in structure for HTBControl */
typedef struct PVRSRV_BRIDGE_IN_HTBCONTROL_TAG
{
IMG_UINT32 *pui32GroupEnable;
IMG_UINT32 ui32EnablePID;
IMG_UINT32 ui32LogLevel;
IMG_UINT32 ui32LogMode;
IMG_UINT32 ui32NumGroups;
IMG_UINT32 ui32OpMode;
} __packed PVRSRV_BRIDGE_IN_HTBCONTROL;
/* Bridge out structure for HTBControl */
typedef struct PVRSRV_BRIDGE_OUT_HTBCONTROL_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_HTBCONTROL;
#endif /* COMMON_HTBUFFER_BRIDGE_H */

View File

@@ -0,0 +1,737 @@
/*******************************************************************************
@File
@Title Common bridge header for mm
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for mm
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_MM_BRIDGE_H
#define COMMON_MM_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "pvrsrv_memallocflags.h"
#include "pvrsrv_memalloc_physheap.h"
#include "devicemem_typedefs.h"
#define PVRSRV_BRIDGE_MM_CMD_FIRST 0
#define PVRSRV_BRIDGE_MM_PMREXPORTPMR PVRSRV_BRIDGE_MM_CMD_FIRST+0
#define PVRSRV_BRIDGE_MM_PMRUNEXPORTPMR PVRSRV_BRIDGE_MM_CMD_FIRST+1
#define PVRSRV_BRIDGE_MM_PMRGETUID PVRSRV_BRIDGE_MM_CMD_FIRST+2
#define PVRSRV_BRIDGE_MM_PMRMAKELOCALIMPORTHANDLE PVRSRV_BRIDGE_MM_CMD_FIRST+3
#define PVRSRV_BRIDGE_MM_PMRUNMAKELOCALIMPORTHANDLE PVRSRV_BRIDGE_MM_CMD_FIRST+4
#define PVRSRV_BRIDGE_MM_PMRIMPORTPMR PVRSRV_BRIDGE_MM_CMD_FIRST+5
#define PVRSRV_BRIDGE_MM_PMRLOCALIMPORTPMR PVRSRV_BRIDGE_MM_CMD_FIRST+6
#define PVRSRV_BRIDGE_MM_PMRUNREFPMR PVRSRV_BRIDGE_MM_CMD_FIRST+7
#define PVRSRV_BRIDGE_MM_PHYSMEMNEWRAMBACKEDPMR PVRSRV_BRIDGE_MM_CMD_FIRST+8
#define PVRSRV_BRIDGE_MM_DEVMEMINTCTXCREATE PVRSRV_BRIDGE_MM_CMD_FIRST+9
#define PVRSRV_BRIDGE_MM_DEVMEMINTCTXDESTROY PVRSRV_BRIDGE_MM_CMD_FIRST+10
#define PVRSRV_BRIDGE_MM_DEVMEMINTHEAPCREATE PVRSRV_BRIDGE_MM_CMD_FIRST+11
#define PVRSRV_BRIDGE_MM_DEVMEMINTHEAPDESTROY PVRSRV_BRIDGE_MM_CMD_FIRST+12
#define PVRSRV_BRIDGE_MM_DEVMEMINTMAPPMR PVRSRV_BRIDGE_MM_CMD_FIRST+13
#define PVRSRV_BRIDGE_MM_DEVMEMINTUNMAPPMR PVRSRV_BRIDGE_MM_CMD_FIRST+14
#define PVRSRV_BRIDGE_MM_DEVMEMINTRESERVERANGE PVRSRV_BRIDGE_MM_CMD_FIRST+15
#define PVRSRV_BRIDGE_MM_DEVMEMINTRESERVERANGEANDMAPPMR PVRSRV_BRIDGE_MM_CMD_FIRST+16
#define PVRSRV_BRIDGE_MM_DEVMEMINTUNRESERVERANGE PVRSRV_BRIDGE_MM_CMD_FIRST+17
#define PVRSRV_BRIDGE_MM_CHANGESPARSEMEM PVRSRV_BRIDGE_MM_CMD_FIRST+18
#define PVRSRV_BRIDGE_MM_DEVMEMISVDEVADDRVALID PVRSRV_BRIDGE_MM_CMD_FIRST+19
#define PVRSRV_BRIDGE_MM_DEVMEMINVALIDATEFBSCTABLE PVRSRV_BRIDGE_MM_CMD_FIRST+20
#define PVRSRV_BRIDGE_MM_HEAPCFGHEAPCONFIGCOUNT PVRSRV_BRIDGE_MM_CMD_FIRST+21
#define PVRSRV_BRIDGE_MM_HEAPCFGHEAPCOUNT PVRSRV_BRIDGE_MM_CMD_FIRST+22
#define PVRSRV_BRIDGE_MM_HEAPCFGHEAPCONFIGNAME PVRSRV_BRIDGE_MM_CMD_FIRST+23
#define PVRSRV_BRIDGE_MM_HEAPCFGHEAPDETAILS PVRSRV_BRIDGE_MM_CMD_FIRST+24
#define PVRSRV_BRIDGE_MM_DEVMEMINTREGISTERPFNOTIFYKM PVRSRV_BRIDGE_MM_CMD_FIRST+25
#define PVRSRV_BRIDGE_MM_PHYSHEAPGETMEMINFO PVRSRV_BRIDGE_MM_CMD_FIRST+26
#define PVRSRV_BRIDGE_MM_GETDEFAULTPHYSICALHEAP PVRSRV_BRIDGE_MM_CMD_FIRST+27
#define PVRSRV_BRIDGE_MM_DEVMEMGETFAULTADDRESS PVRSRV_BRIDGE_MM_CMD_FIRST+28
#define PVRSRV_BRIDGE_MM_PVRSRVSTATSUPDATEOOMSTAT PVRSRV_BRIDGE_MM_CMD_FIRST+29
#define PVRSRV_BRIDGE_MM_DEVMEMXINTRESERVERANGE PVRSRV_BRIDGE_MM_CMD_FIRST+30
#define PVRSRV_BRIDGE_MM_DEVMEMXINTUNRESERVERANGE PVRSRV_BRIDGE_MM_CMD_FIRST+31
#define PVRSRV_BRIDGE_MM_DEVMEMXINTMAPPAGES PVRSRV_BRIDGE_MM_CMD_FIRST+32
#define PVRSRV_BRIDGE_MM_DEVMEMXINTUNMAPPAGES PVRSRV_BRIDGE_MM_CMD_FIRST+33
#define PVRSRV_BRIDGE_MM_DEVMEMXINTMAPVRANGETOBACKINGPAGE PVRSRV_BRIDGE_MM_CMD_FIRST+34
#define PVRSRV_BRIDGE_MM_CMD_LAST (PVRSRV_BRIDGE_MM_CMD_FIRST+34)
/*******************************************
PMRExportPMR
*******************************************/
/* Bridge in structure for PMRExportPMR */
typedef struct PVRSRV_BRIDGE_IN_PMREXPORTPMR_TAG
{
IMG_HANDLE hPMR;
} __packed PVRSRV_BRIDGE_IN_PMREXPORTPMR;
/* Bridge out structure for PMRExportPMR */
typedef struct PVRSRV_BRIDGE_OUT_PMREXPORTPMR_TAG
{
IMG_UINT64 ui64Password;
IMG_UINT64 ui64Size;
IMG_HANDLE hPMRExport;
PVRSRV_ERROR eError;
IMG_UINT32 ui32Log2Contig;
} __packed PVRSRV_BRIDGE_OUT_PMREXPORTPMR;
/*******************************************
PMRUnexportPMR
*******************************************/
/* Bridge in structure for PMRUnexportPMR */
typedef struct PVRSRV_BRIDGE_IN_PMRUNEXPORTPMR_TAG
{
IMG_HANDLE hPMRExport;
} __packed PVRSRV_BRIDGE_IN_PMRUNEXPORTPMR;
/* Bridge out structure for PMRUnexportPMR */
typedef struct PVRSRV_BRIDGE_OUT_PMRUNEXPORTPMR_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_PMRUNEXPORTPMR;
/*******************************************
PMRGetUID
*******************************************/
/* Bridge in structure for PMRGetUID */
typedef struct PVRSRV_BRIDGE_IN_PMRGETUID_TAG
{
IMG_HANDLE hPMR;
} __packed PVRSRV_BRIDGE_IN_PMRGETUID;
/* Bridge out structure for PMRGetUID */
typedef struct PVRSRV_BRIDGE_OUT_PMRGETUID_TAG
{
IMG_UINT64 ui64UID;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_PMRGETUID;
/*******************************************
PMRMakeLocalImportHandle
*******************************************/
/* Bridge in structure for PMRMakeLocalImportHandle */
typedef struct PVRSRV_BRIDGE_IN_PMRMAKELOCALIMPORTHANDLE_TAG
{
IMG_HANDLE hBuffer;
} __packed PVRSRV_BRIDGE_IN_PMRMAKELOCALIMPORTHANDLE;
/* Bridge out structure for PMRMakeLocalImportHandle */
typedef struct PVRSRV_BRIDGE_OUT_PMRMAKELOCALIMPORTHANDLE_TAG
{
IMG_HANDLE hExtMem;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_PMRMAKELOCALIMPORTHANDLE;
/*******************************************
PMRUnmakeLocalImportHandle
*******************************************/
/* Bridge in structure for PMRUnmakeLocalImportHandle */
typedef struct PVRSRV_BRIDGE_IN_PMRUNMAKELOCALIMPORTHANDLE_TAG
{
IMG_HANDLE hExtMem;
} __packed PVRSRV_BRIDGE_IN_PMRUNMAKELOCALIMPORTHANDLE;
/* Bridge out structure for PMRUnmakeLocalImportHandle */
typedef struct PVRSRV_BRIDGE_OUT_PMRUNMAKELOCALIMPORTHANDLE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_PMRUNMAKELOCALIMPORTHANDLE;
/*******************************************
PMRImportPMR
*******************************************/
/* Bridge in structure for PMRImportPMR */
typedef struct PVRSRV_BRIDGE_IN_PMRIMPORTPMR_TAG
{
IMG_UINT64 ui64uiPassword;
IMG_UINT64 ui64uiSize;
IMG_HANDLE hPMRExport;
IMG_UINT32 ui32uiLog2Contig;
} __packed PVRSRV_BRIDGE_IN_PMRIMPORTPMR;
/* Bridge out structure for PMRImportPMR */
typedef struct PVRSRV_BRIDGE_OUT_PMRIMPORTPMR_TAG
{
IMG_HANDLE hPMR;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_PMRIMPORTPMR;
/*******************************************
PMRLocalImportPMR
*******************************************/
/* Bridge in structure for PMRLocalImportPMR */
typedef struct PVRSRV_BRIDGE_IN_PMRLOCALIMPORTPMR_TAG
{
IMG_HANDLE hExtHandle;
} __packed PVRSRV_BRIDGE_IN_PMRLOCALIMPORTPMR;
/* Bridge out structure for PMRLocalImportPMR */
typedef struct PVRSRV_BRIDGE_OUT_PMRLOCALIMPORTPMR_TAG
{
IMG_DEVMEM_ALIGN_T uiAlign;
IMG_DEVMEM_SIZE_T uiSize;
IMG_HANDLE hPMR;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_PMRLOCALIMPORTPMR;
/*******************************************
PMRUnrefPMR
*******************************************/
/* Bridge in structure for PMRUnrefPMR */
typedef struct PVRSRV_BRIDGE_IN_PMRUNREFPMR_TAG
{
IMG_HANDLE hPMR;
} __packed PVRSRV_BRIDGE_IN_PMRUNREFPMR;
/* Bridge out structure for PMRUnrefPMR */
typedef struct PVRSRV_BRIDGE_OUT_PMRUNREFPMR_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_PMRUNREFPMR;
/*******************************************
PhysmemNewRamBackedPMR
*******************************************/
/* Bridge in structure for PhysmemNewRamBackedPMR */
typedef struct PVRSRV_BRIDGE_IN_PHYSMEMNEWRAMBACKEDPMR_TAG
{
IMG_DEVMEM_SIZE_T uiSize;
IMG_UINT32 *pui32MappingTable;
const IMG_CHAR *puiAnnotation;
IMG_UINT32 ui32AnnotationLength;
IMG_UINT32 ui32Log2PageSize;
IMG_UINT32 ui32NumPhysChunks;
IMG_UINT32 ui32NumVirtChunks;
IMG_UINT32 ui32PDumpFlags;
IMG_PID ui32PID;
PVRSRV_MEMALLOCFLAGS_T uiFlags;
} __packed PVRSRV_BRIDGE_IN_PHYSMEMNEWRAMBACKEDPMR;
/* Bridge out structure for PhysmemNewRamBackedPMR */
typedef struct PVRSRV_BRIDGE_OUT_PHYSMEMNEWRAMBACKEDPMR_TAG
{
IMG_HANDLE hPMRPtr;
PVRSRV_ERROR eError;
PVRSRV_MEMALLOCFLAGS_T uiOutFlags;
} __packed PVRSRV_BRIDGE_OUT_PHYSMEMNEWRAMBACKEDPMR;
/*******************************************
DevmemIntCtxCreate
*******************************************/
/* Bridge in structure for DevmemIntCtxCreate */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINTCTXCREATE_TAG
{
IMG_BOOL bbKernelMemoryCtx;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINTCTXCREATE;
/* Bridge out structure for DevmemIntCtxCreate */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINTCTXCREATE_TAG
{
IMG_HANDLE hDevMemServerContext;
IMG_HANDLE hPrivData;
PVRSRV_ERROR eError;
IMG_UINT32 ui32CPUCacheLineSize;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINTCTXCREATE;
/*******************************************
DevmemIntCtxDestroy
*******************************************/
/* Bridge in structure for DevmemIntCtxDestroy */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINTCTXDESTROY_TAG
{
IMG_HANDLE hDevmemServerContext;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINTCTXDESTROY;
/* Bridge out structure for DevmemIntCtxDestroy */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINTCTXDESTROY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINTCTXDESTROY;
/*******************************************
DevmemIntHeapCreate
*******************************************/
/* Bridge in structure for DevmemIntHeapCreate */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINTHEAPCREATE_TAG
{
IMG_HANDLE hDevmemCtx;
IMG_UINT32 ui32HeapConfigIndex;
IMG_UINT32 ui32HeapIndex;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINTHEAPCREATE;
/* Bridge out structure for DevmemIntHeapCreate */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINTHEAPCREATE_TAG
{
IMG_HANDLE hDevmemHeapPtr;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINTHEAPCREATE;
/*******************************************
DevmemIntHeapDestroy
*******************************************/
/* Bridge in structure for DevmemIntHeapDestroy */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINTHEAPDESTROY_TAG
{
IMG_HANDLE hDevmemHeap;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINTHEAPDESTROY;
/* Bridge out structure for DevmemIntHeapDestroy */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINTHEAPDESTROY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINTHEAPDESTROY;
/*******************************************
DevmemIntMapPMR
*******************************************/
/* Bridge in structure for DevmemIntMapPMR */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINTMAPPMR_TAG
{
IMG_HANDLE hPMR;
IMG_HANDLE hReservation;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINTMAPPMR;
/* Bridge out structure for DevmemIntMapPMR */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINTMAPPMR_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINTMAPPMR;
/*******************************************
DevmemIntUnmapPMR
*******************************************/
/* Bridge in structure for DevmemIntUnmapPMR */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINTUNMAPPMR_TAG
{
IMG_HANDLE hReservation;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINTUNMAPPMR;
/* Bridge out structure for DevmemIntUnmapPMR */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINTUNMAPPMR_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINTUNMAPPMR;
/*******************************************
DevmemIntReserveRange
*******************************************/
/* Bridge in structure for DevmemIntReserveRange */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINTRESERVERANGE_TAG
{
IMG_DEV_VIRTADDR sAddress;
IMG_DEVMEM_SIZE_T uiLength;
IMG_HANDLE hDevmemServerHeap;
PVRSRV_MEMALLOCFLAGS_T uiFlags;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINTRESERVERANGE;
/* Bridge out structure for DevmemIntReserveRange */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINTRESERVERANGE_TAG
{
IMG_HANDLE hReservation;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINTRESERVERANGE;
/*******************************************
DevmemIntReserveRangeAndMapPMR
*******************************************/
/* Bridge in structure for DevmemIntReserveRangeAndMapPMR */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINTRESERVERANGEANDMAPPMR_TAG
{
IMG_DEV_VIRTADDR sAddress;
IMG_DEVMEM_SIZE_T uiLength;
IMG_HANDLE hDevmemServerHeap;
IMG_HANDLE hPMR;
PVRSRV_MEMALLOCFLAGS_T uiFlags;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINTRESERVERANGEANDMAPPMR;
/* Bridge out structure for DevmemIntReserveRangeAndMapPMR */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINTRESERVERANGEANDMAPPMR_TAG
{
IMG_HANDLE hReservation;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINTRESERVERANGEANDMAPPMR;
/*******************************************
DevmemIntUnreserveRange
*******************************************/
/* Bridge in structure for DevmemIntUnreserveRange */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINTUNRESERVERANGE_TAG
{
IMG_HANDLE hReservation;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINTUNRESERVERANGE;
/* Bridge out structure for DevmemIntUnreserveRange */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINTUNRESERVERANGE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINTUNRESERVERANGE;
/*******************************************
ChangeSparseMem
*******************************************/
/* Bridge in structure for ChangeSparseMem */
typedef struct PVRSRV_BRIDGE_IN_CHANGESPARSEMEM_TAG
{
IMG_HANDLE hReservation;
IMG_UINT32 *pui32AllocPageIndices;
IMG_UINT32 *pui32FreePageIndices;
IMG_UINT32 ui32AllocPageCount;
IMG_UINT32 ui32FreePageCount;
IMG_UINT32 ui32SparseFlags;
} __packed PVRSRV_BRIDGE_IN_CHANGESPARSEMEM;
/* Bridge out structure for ChangeSparseMem */
typedef struct PVRSRV_BRIDGE_OUT_CHANGESPARSEMEM_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_CHANGESPARSEMEM;
/*******************************************
DevmemIsVDevAddrValid
*******************************************/
/* Bridge in structure for DevmemIsVDevAddrValid */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMISVDEVADDRVALID_TAG
{
IMG_DEV_VIRTADDR sAddress;
IMG_HANDLE hDevmemCtx;
} __packed PVRSRV_BRIDGE_IN_DEVMEMISVDEVADDRVALID;
/* Bridge out structure for DevmemIsVDevAddrValid */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMISVDEVADDRVALID_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMISVDEVADDRVALID;
/*******************************************
DevmemInvalidateFBSCTable
*******************************************/
/* Bridge in structure for DevmemInvalidateFBSCTable */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINVALIDATEFBSCTABLE_TAG
{
IMG_UINT64 ui64FBSCEntries;
IMG_HANDLE hDevmemCtx;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINVALIDATEFBSCTABLE;
/* Bridge out structure for DevmemInvalidateFBSCTable */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINVALIDATEFBSCTABLE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINVALIDATEFBSCTABLE;
/*******************************************
HeapCfgHeapConfigCount
*******************************************/
/* Bridge in structure for HeapCfgHeapConfigCount */
typedef struct PVRSRV_BRIDGE_IN_HEAPCFGHEAPCONFIGCOUNT_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_HEAPCFGHEAPCONFIGCOUNT;
/* Bridge out structure for HeapCfgHeapConfigCount */
typedef struct PVRSRV_BRIDGE_OUT_HEAPCFGHEAPCONFIGCOUNT_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32NumHeapConfigs;
} __packed PVRSRV_BRIDGE_OUT_HEAPCFGHEAPCONFIGCOUNT;
/*******************************************
HeapCfgHeapCount
*******************************************/
/* Bridge in structure for HeapCfgHeapCount */
typedef struct PVRSRV_BRIDGE_IN_HEAPCFGHEAPCOUNT_TAG
{
IMG_UINT32 ui32HeapConfigIndex;
} __packed PVRSRV_BRIDGE_IN_HEAPCFGHEAPCOUNT;
/* Bridge out structure for HeapCfgHeapCount */
typedef struct PVRSRV_BRIDGE_OUT_HEAPCFGHEAPCOUNT_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32NumHeaps;
} __packed PVRSRV_BRIDGE_OUT_HEAPCFGHEAPCOUNT;
/*******************************************
HeapCfgHeapConfigName
*******************************************/
/* Bridge in structure for HeapCfgHeapConfigName */
typedef struct PVRSRV_BRIDGE_IN_HEAPCFGHEAPCONFIGNAME_TAG
{
IMG_CHAR *puiHeapConfigName;
IMG_UINT32 ui32HeapConfigIndex;
IMG_UINT32 ui32HeapConfigNameBufSz;
} __packed PVRSRV_BRIDGE_IN_HEAPCFGHEAPCONFIGNAME;
/* Bridge out structure for HeapCfgHeapConfigName */
typedef struct PVRSRV_BRIDGE_OUT_HEAPCFGHEAPCONFIGNAME_TAG
{
IMG_CHAR *puiHeapConfigName;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_HEAPCFGHEAPCONFIGNAME;
/*******************************************
HeapCfgHeapDetails
*******************************************/
/* Bridge in structure for HeapCfgHeapDetails */
typedef struct PVRSRV_BRIDGE_IN_HEAPCFGHEAPDETAILS_TAG
{
IMG_CHAR *puiHeapNameOut;
IMG_UINT32 ui32HeapConfigIndex;
IMG_UINT32 ui32HeapIndex;
IMG_UINT32 ui32HeapNameBufSz;
} __packed PVRSRV_BRIDGE_IN_HEAPCFGHEAPDETAILS;
/* Bridge out structure for HeapCfgHeapDetails */
typedef struct PVRSRV_BRIDGE_OUT_HEAPCFGHEAPDETAILS_TAG
{
IMG_DEV_VIRTADDR sDevVAddrBase;
IMG_DEVMEM_SIZE_T uiHeapLength;
IMG_DEVMEM_SIZE_T uiReservedRegionLength;
IMG_CHAR *puiHeapNameOut;
PVRSRV_ERROR eError;
IMG_UINT32 ui32Log2DataPageSizeOut;
IMG_UINT32 ui32Log2ImportAlignmentOut;
} __packed PVRSRV_BRIDGE_OUT_HEAPCFGHEAPDETAILS;
/*******************************************
DevmemIntRegisterPFNotifyKM
*******************************************/
/* Bridge in structure for DevmemIntRegisterPFNotifyKM */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMINTREGISTERPFNOTIFYKM_TAG
{
IMG_HANDLE hDevmemCtx;
IMG_BOOL bRegister;
} __packed PVRSRV_BRIDGE_IN_DEVMEMINTREGISTERPFNOTIFYKM;
/* Bridge out structure for DevmemIntRegisterPFNotifyKM */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMINTREGISTERPFNOTIFYKM_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMINTREGISTERPFNOTIFYKM;
/*******************************************
PhysHeapGetMemInfo
*******************************************/
/* Bridge in structure for PhysHeapGetMemInfo */
typedef struct PVRSRV_BRIDGE_IN_PHYSHEAPGETMEMINFO_TAG
{
PHYS_HEAP_MEM_STATS *pasapPhysHeapMemStats;
PVRSRV_PHYS_HEAP *peaPhysHeapID;
IMG_UINT32 ui32PhysHeapCount;
} __packed PVRSRV_BRIDGE_IN_PHYSHEAPGETMEMINFO;
/* Bridge out structure for PhysHeapGetMemInfo */
typedef struct PVRSRV_BRIDGE_OUT_PHYSHEAPGETMEMINFO_TAG
{
PHYS_HEAP_MEM_STATS *pasapPhysHeapMemStats;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_PHYSHEAPGETMEMINFO;
/*******************************************
GetDefaultPhysicalHeap
*******************************************/
/* Bridge in structure for GetDefaultPhysicalHeap */
typedef struct PVRSRV_BRIDGE_IN_GETDEFAULTPHYSICALHEAP_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_GETDEFAULTPHYSICALHEAP;
/* Bridge out structure for GetDefaultPhysicalHeap */
typedef struct PVRSRV_BRIDGE_OUT_GETDEFAULTPHYSICALHEAP_TAG
{
PVRSRV_ERROR eError;
PVRSRV_PHYS_HEAP eHeap;
} __packed PVRSRV_BRIDGE_OUT_GETDEFAULTPHYSICALHEAP;
/*******************************************
DevmemGetFaultAddress
*******************************************/
/* Bridge in structure for DevmemGetFaultAddress */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMGETFAULTADDRESS_TAG
{
IMG_HANDLE hDevmemCtx;
} __packed PVRSRV_BRIDGE_IN_DEVMEMGETFAULTADDRESS;
/* Bridge out structure for DevmemGetFaultAddress */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMGETFAULTADDRESS_TAG
{
IMG_DEV_VIRTADDR sFaultAddress;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMGETFAULTADDRESS;
/*******************************************
PVRSRVStatsUpdateOOMStat
*******************************************/
/* Bridge in structure for PVRSRVStatsUpdateOOMStat */
typedef struct PVRSRV_BRIDGE_IN_PVRSRVSTATSUPDATEOOMSTAT_TAG
{
IMG_PID ui32pid;
IMG_UINT32 ui32ui32StatType;
} __packed PVRSRV_BRIDGE_IN_PVRSRVSTATSUPDATEOOMSTAT;
/* Bridge out structure for PVRSRVStatsUpdateOOMStat */
typedef struct PVRSRV_BRIDGE_OUT_PVRSRVSTATSUPDATEOOMSTAT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_PVRSRVSTATSUPDATEOOMSTAT;
/*******************************************
DevmemXIntReserveRange
*******************************************/
/* Bridge in structure for DevmemXIntReserveRange */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMXINTRESERVERANGE_TAG
{
IMG_DEV_VIRTADDR sAddress;
IMG_DEVMEM_SIZE_T uiLength;
IMG_HANDLE hDevmemServerHeap;
} __packed PVRSRV_BRIDGE_IN_DEVMEMXINTRESERVERANGE;
/* Bridge out structure for DevmemXIntReserveRange */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMXINTRESERVERANGE_TAG
{
IMG_HANDLE hReservation;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMXINTRESERVERANGE;
/*******************************************
DevmemXIntUnreserveRange
*******************************************/
/* Bridge in structure for DevmemXIntUnreserveRange */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMXINTUNRESERVERANGE_TAG
{
IMG_HANDLE hReservation;
} __packed PVRSRV_BRIDGE_IN_DEVMEMXINTUNRESERVERANGE;
/* Bridge out structure for DevmemXIntUnreserveRange */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMXINTUNRESERVERANGE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMXINTUNRESERVERANGE;
/*******************************************
DevmemXIntMapPages
*******************************************/
/* Bridge in structure for DevmemXIntMapPages */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMXINTMAPPAGES_TAG
{
IMG_HANDLE hPMR;
IMG_HANDLE hReservation;
IMG_UINT32 ui32PageCount;
IMG_UINT32 ui32PhysPageOffset;
IMG_UINT32 ui32VirtPageOffset;
PVRSRV_MEMALLOCFLAGS_T uiFlags;
} __packed PVRSRV_BRIDGE_IN_DEVMEMXINTMAPPAGES;
/* Bridge out structure for DevmemXIntMapPages */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMXINTMAPPAGES_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMXINTMAPPAGES;
/*******************************************
DevmemXIntUnmapPages
*******************************************/
/* Bridge in structure for DevmemXIntUnmapPages */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMXINTUNMAPPAGES_TAG
{
IMG_HANDLE hReservation;
IMG_UINT32 ui32PageCount;
IMG_UINT32 ui32VirtPageOffset;
} __packed PVRSRV_BRIDGE_IN_DEVMEMXINTUNMAPPAGES;
/* Bridge out structure for DevmemXIntUnmapPages */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMXINTUNMAPPAGES_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMXINTUNMAPPAGES;
/*******************************************
DevmemXIntMapVRangeToBackingPage
*******************************************/
/* Bridge in structure for DevmemXIntMapVRangeToBackingPage */
typedef struct PVRSRV_BRIDGE_IN_DEVMEMXINTMAPVRANGETOBACKINGPAGE_TAG
{
IMG_HANDLE hReservation;
IMG_UINT32 ui32PageCount;
IMG_UINT32 ui32VirtPageOffset;
PVRSRV_MEMALLOCFLAGS_T uiFlags;
} __packed PVRSRV_BRIDGE_IN_DEVMEMXINTMAPVRANGETOBACKINGPAGE;
/* Bridge out structure for DevmemXIntMapVRangeToBackingPage */
typedef struct PVRSRV_BRIDGE_OUT_DEVMEMXINTMAPVRANGETOBACKINGPAGE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DEVMEMXINTMAPVRANGETOBACKINGPAGE;
#endif /* COMMON_MM_BRIDGE_H */

View File

@@ -0,0 +1,80 @@
/*******************************************************************************
@File
@Title Common bridge header for mmextmem
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for mmextmem
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_MMEXTMEM_BRIDGE_H
#define COMMON_MMEXTMEM_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "pvrsrv_memallocflags.h"
#include "devicemem_typedefs.h"
#define PVRSRV_BRIDGE_MMEXTMEM_CMD_FIRST 0
#define PVRSRV_BRIDGE_MMEXTMEM_PHYSMEMWRAPEXTMEM PVRSRV_BRIDGE_MMEXTMEM_CMD_FIRST+0
#define PVRSRV_BRIDGE_MMEXTMEM_CMD_LAST (PVRSRV_BRIDGE_MMEXTMEM_CMD_FIRST+0)
/*******************************************
PhysmemWrapExtMem
*******************************************/
/* Bridge in structure for PhysmemWrapExtMem */
typedef struct PVRSRV_BRIDGE_IN_PHYSMEMWRAPEXTMEM_TAG
{
IMG_UINT64 ui64CpuVAddr;
IMG_DEVMEM_SIZE_T uiSize;
PVRSRV_MEMALLOCFLAGS_T uiFlags;
} __packed PVRSRV_BRIDGE_IN_PHYSMEMWRAPEXTMEM;
/* Bridge out structure for PhysmemWrapExtMem */
typedef struct PVRSRV_BRIDGE_OUT_PHYSMEMWRAPEXTMEM_TAG
{
IMG_HANDLE hPMRPtr;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_PHYSMEMWRAPEXTMEM;
#endif /* COMMON_MMEXTMEM_BRIDGE_H */

View File

@@ -0,0 +1,214 @@
/*******************************************************************************
@File
@Title Common bridge header for pvrtl
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for pvrtl
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_PVRTL_BRIDGE_H
#define COMMON_PVRTL_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "devicemem_typedefs.h"
#include "pvrsrv_tlcommon.h"
#define PVRSRV_BRIDGE_PVRTL_CMD_FIRST 0
#define PVRSRV_BRIDGE_PVRTL_TLOPENSTREAM PVRSRV_BRIDGE_PVRTL_CMD_FIRST+0
#define PVRSRV_BRIDGE_PVRTL_TLCLOSESTREAM PVRSRV_BRIDGE_PVRTL_CMD_FIRST+1
#define PVRSRV_BRIDGE_PVRTL_TLACQUIREDATA PVRSRV_BRIDGE_PVRTL_CMD_FIRST+2
#define PVRSRV_BRIDGE_PVRTL_TLRELEASEDATA PVRSRV_BRIDGE_PVRTL_CMD_FIRST+3
#define PVRSRV_BRIDGE_PVRTL_TLDISCOVERSTREAMS PVRSRV_BRIDGE_PVRTL_CMD_FIRST+4
#define PVRSRV_BRIDGE_PVRTL_TLRESERVESTREAM PVRSRV_BRIDGE_PVRTL_CMD_FIRST+5
#define PVRSRV_BRIDGE_PVRTL_TLCOMMITSTREAM PVRSRV_BRIDGE_PVRTL_CMD_FIRST+6
#define PVRSRV_BRIDGE_PVRTL_TLWRITEDATA PVRSRV_BRIDGE_PVRTL_CMD_FIRST+7
#define PVRSRV_BRIDGE_PVRTL_CMD_LAST (PVRSRV_BRIDGE_PVRTL_CMD_FIRST+7)
/*******************************************
TLOpenStream
*******************************************/
/* Bridge in structure for TLOpenStream */
typedef struct PVRSRV_BRIDGE_IN_TLOPENSTREAM_TAG
{
const IMG_CHAR *puiName;
IMG_UINT32 ui32Mode;
} __packed PVRSRV_BRIDGE_IN_TLOPENSTREAM;
/* Bridge out structure for TLOpenStream */
typedef struct PVRSRV_BRIDGE_OUT_TLOPENSTREAM_TAG
{
IMG_HANDLE hSD;
IMG_HANDLE hTLPMR;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_TLOPENSTREAM;
/*******************************************
TLCloseStream
*******************************************/
/* Bridge in structure for TLCloseStream */
typedef struct PVRSRV_BRIDGE_IN_TLCLOSESTREAM_TAG
{
IMG_HANDLE hSD;
} __packed PVRSRV_BRIDGE_IN_TLCLOSESTREAM;
/* Bridge out structure for TLCloseStream */
typedef struct PVRSRV_BRIDGE_OUT_TLCLOSESTREAM_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_TLCLOSESTREAM;
/*******************************************
TLAcquireData
*******************************************/
/* Bridge in structure for TLAcquireData */
typedef struct PVRSRV_BRIDGE_IN_TLACQUIREDATA_TAG
{
IMG_HANDLE hSD;
} __packed PVRSRV_BRIDGE_IN_TLACQUIREDATA;
/* Bridge out structure for TLAcquireData */
typedef struct PVRSRV_BRIDGE_OUT_TLACQUIREDATA_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32ReadLen;
IMG_UINT32 ui32ReadOffset;
} __packed PVRSRV_BRIDGE_OUT_TLACQUIREDATA;
/*******************************************
TLReleaseData
*******************************************/
/* Bridge in structure for TLReleaseData */
typedef struct PVRSRV_BRIDGE_IN_TLRELEASEDATA_TAG
{
IMG_HANDLE hSD;
IMG_UINT32 ui32ReadLen;
IMG_UINT32 ui32ReadOffset;
} __packed PVRSRV_BRIDGE_IN_TLRELEASEDATA;
/* Bridge out structure for TLReleaseData */
typedef struct PVRSRV_BRIDGE_OUT_TLRELEASEDATA_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_TLRELEASEDATA;
/*******************************************
TLDiscoverStreams
*******************************************/
/* Bridge in structure for TLDiscoverStreams */
typedef struct PVRSRV_BRIDGE_IN_TLDISCOVERSTREAMS_TAG
{
const IMG_CHAR *puiNamePattern;
IMG_CHAR *puiStreams;
IMG_UINT32 ui32Size;
} __packed PVRSRV_BRIDGE_IN_TLDISCOVERSTREAMS;
/* Bridge out structure for TLDiscoverStreams */
typedef struct PVRSRV_BRIDGE_OUT_TLDISCOVERSTREAMS_TAG
{
IMG_CHAR *puiStreams;
PVRSRV_ERROR eError;
IMG_UINT32 ui32NumFound;
} __packed PVRSRV_BRIDGE_OUT_TLDISCOVERSTREAMS;
/*******************************************
TLReserveStream
*******************************************/
/* Bridge in structure for TLReserveStream */
typedef struct PVRSRV_BRIDGE_IN_TLRESERVESTREAM_TAG
{
IMG_HANDLE hSD;
IMG_UINT32 ui32Size;
IMG_UINT32 ui32SizeMin;
} __packed PVRSRV_BRIDGE_IN_TLRESERVESTREAM;
/* Bridge out structure for TLReserveStream */
typedef struct PVRSRV_BRIDGE_OUT_TLRESERVESTREAM_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32Available;
IMG_UINT32 ui32BufferOffset;
} __packed PVRSRV_BRIDGE_OUT_TLRESERVESTREAM;
/*******************************************
TLCommitStream
*******************************************/
/* Bridge in structure for TLCommitStream */
typedef struct PVRSRV_BRIDGE_IN_TLCOMMITSTREAM_TAG
{
IMG_HANDLE hSD;
IMG_UINT32 ui32ReqSize;
} __packed PVRSRV_BRIDGE_IN_TLCOMMITSTREAM;
/* Bridge out structure for TLCommitStream */
typedef struct PVRSRV_BRIDGE_OUT_TLCOMMITSTREAM_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_TLCOMMITSTREAM;
/*******************************************
TLWriteData
*******************************************/
/* Bridge in structure for TLWriteData */
typedef struct PVRSRV_BRIDGE_IN_TLWRITEDATA_TAG
{
IMG_HANDLE hSD;
IMG_BYTE *pui8Data;
IMG_UINT32 ui32Size;
} __packed PVRSRV_BRIDGE_IN_TLWRITEDATA;
/* Bridge out structure for TLWriteData */
typedef struct PVRSRV_BRIDGE_OUT_TLWRITEDATA_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_TLWRITEDATA;
#endif /* COMMON_PVRTL_BRIDGE_H */

View File

@@ -0,0 +1,150 @@
/*******************************************************************************
@File
@Title Common bridge header for rgxbreakpoint
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for rgxbreakpoint
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_RGXBREAKPOINT_BRIDGE_H
#define COMMON_RGXBREAKPOINT_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "rgx_bridge.h"
#define PVRSRV_BRIDGE_RGXBREAKPOINT_CMD_FIRST 0
#define PVRSRV_BRIDGE_RGXBREAKPOINT_RGXSETBREAKPOINT PVRSRV_BRIDGE_RGXBREAKPOINT_CMD_FIRST+0
#define PVRSRV_BRIDGE_RGXBREAKPOINT_RGXCLEARBREAKPOINT PVRSRV_BRIDGE_RGXBREAKPOINT_CMD_FIRST+1
#define PVRSRV_BRIDGE_RGXBREAKPOINT_RGXENABLEBREAKPOINT PVRSRV_BRIDGE_RGXBREAKPOINT_CMD_FIRST+2
#define PVRSRV_BRIDGE_RGXBREAKPOINT_RGXDISABLEBREAKPOINT PVRSRV_BRIDGE_RGXBREAKPOINT_CMD_FIRST+3
#define PVRSRV_BRIDGE_RGXBREAKPOINT_RGXOVERALLOCATEBPREGISTERS PVRSRV_BRIDGE_RGXBREAKPOINT_CMD_FIRST+4
#define PVRSRV_BRIDGE_RGXBREAKPOINT_CMD_LAST (PVRSRV_BRIDGE_RGXBREAKPOINT_CMD_FIRST+4)
/*******************************************
RGXSetBreakpoint
*******************************************/
/* Bridge in structure for RGXSetBreakpoint */
typedef struct PVRSRV_BRIDGE_IN_RGXSETBREAKPOINT_TAG
{
IMG_UINT64 ui64TempSpillingAddr;
IMG_HANDLE hPrivData;
IMG_UINT32 eFWDataMaster;
IMG_UINT32 ui32BreakpointAddr;
IMG_UINT32 ui32DM;
IMG_UINT32 ui32HandlerAddr;
} __packed PVRSRV_BRIDGE_IN_RGXSETBREAKPOINT;
/* Bridge out structure for RGXSetBreakpoint */
typedef struct PVRSRV_BRIDGE_OUT_RGXSETBREAKPOINT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXSETBREAKPOINT;
/*******************************************
RGXClearBreakpoint
*******************************************/
/* Bridge in structure for RGXClearBreakpoint */
typedef struct PVRSRV_BRIDGE_IN_RGXCLEARBREAKPOINT_TAG
{
IMG_HANDLE hPrivData;
} __packed PVRSRV_BRIDGE_IN_RGXCLEARBREAKPOINT;
/* Bridge out structure for RGXClearBreakpoint */
typedef struct PVRSRV_BRIDGE_OUT_RGXCLEARBREAKPOINT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCLEARBREAKPOINT;
/*******************************************
RGXEnableBreakpoint
*******************************************/
/* Bridge in structure for RGXEnableBreakpoint */
typedef struct PVRSRV_BRIDGE_IN_RGXENABLEBREAKPOINT_TAG
{
IMG_HANDLE hPrivData;
} __packed PVRSRV_BRIDGE_IN_RGXENABLEBREAKPOINT;
/* Bridge out structure for RGXEnableBreakpoint */
typedef struct PVRSRV_BRIDGE_OUT_RGXENABLEBREAKPOINT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXENABLEBREAKPOINT;
/*******************************************
RGXDisableBreakpoint
*******************************************/
/* Bridge in structure for RGXDisableBreakpoint */
typedef struct PVRSRV_BRIDGE_IN_RGXDISABLEBREAKPOINT_TAG
{
IMG_HANDLE hPrivData;
} __packed PVRSRV_BRIDGE_IN_RGXDISABLEBREAKPOINT;
/* Bridge out structure for RGXDisableBreakpoint */
typedef struct PVRSRV_BRIDGE_OUT_RGXDISABLEBREAKPOINT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXDISABLEBREAKPOINT;
/*******************************************
RGXOverallocateBPRegisters
*******************************************/
/* Bridge in structure for RGXOverallocateBPRegisters */
typedef struct PVRSRV_BRIDGE_IN_RGXOVERALLOCATEBPREGISTERS_TAG
{
IMG_UINT32 ui32SharedRegs;
IMG_UINT32 ui32TempRegs;
} __packed PVRSRV_BRIDGE_IN_RGXOVERALLOCATEBPREGISTERS;
/* Bridge out structure for RGXOverallocateBPRegisters */
typedef struct PVRSRV_BRIDGE_OUT_RGXOVERALLOCATEBPREGISTERS_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXOVERALLOCATEBPREGISTERS;
#endif /* COMMON_RGXBREAKPOINT_BRIDGE_H */

View File

@@ -0,0 +1,289 @@
/*******************************************************************************
@File
@Title Common bridge header for rgxcmp
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for rgxcmp
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_RGXCMP_BRIDGE_H
#define COMMON_RGXCMP_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "rgx_bridge.h"
#include "pvrsrv_sync_km.h"
#define PVRSRV_BRIDGE_RGXCMP_CMD_FIRST 0
#define PVRSRV_BRIDGE_RGXCMP_RGXCREATECOMPUTECONTEXT PVRSRV_BRIDGE_RGXCMP_CMD_FIRST+0
#define PVRSRV_BRIDGE_RGXCMP_RGXDESTROYCOMPUTECONTEXT PVRSRV_BRIDGE_RGXCMP_CMD_FIRST+1
#define PVRSRV_BRIDGE_RGXCMP_RGXFLUSHCOMPUTEDATA PVRSRV_BRIDGE_RGXCMP_CMD_FIRST+2
#define PVRSRV_BRIDGE_RGXCMP_RGXSENDCANCELCMD PVRSRV_BRIDGE_RGXCMP_CMD_FIRST+3
#define PVRSRV_BRIDGE_RGXCMP_RGXSETCOMPUTECONTEXTPRIORITY PVRSRV_BRIDGE_RGXCMP_CMD_FIRST+4
#define PVRSRV_BRIDGE_RGXCMP_RGXNOTIFYCOMPUTEWRITEOFFSETUPDATE PVRSRV_BRIDGE_RGXCMP_CMD_FIRST+5
#define PVRSRV_BRIDGE_RGXCMP_RGXGETLASTDEVICEERROR PVRSRV_BRIDGE_RGXCMP_CMD_FIRST+6
#define PVRSRV_BRIDGE_RGXCMP_RGXKICKTIMESTAMPQUERY PVRSRV_BRIDGE_RGXCMP_CMD_FIRST+7
#define PVRSRV_BRIDGE_RGXCMP_RGXKICKCDM PVRSRV_BRIDGE_RGXCMP_CMD_FIRST+8
#define PVRSRV_BRIDGE_RGXCMP_RGXCDMGETSHAREDMEMORY PVRSRV_BRIDGE_RGXCMP_CMD_FIRST+9
#define PVRSRV_BRIDGE_RGXCMP_RGXCDMRELEASESHAREDMEMORY PVRSRV_BRIDGE_RGXCMP_CMD_FIRST+10
#define PVRSRV_BRIDGE_RGXCMP_CMD_LAST (PVRSRV_BRIDGE_RGXCMP_CMD_FIRST+10)
/*******************************************
RGXCreateComputeContext
*******************************************/
/* Bridge in structure for RGXCreateComputeContext */
typedef struct PVRSRV_BRIDGE_IN_RGXCREATECOMPUTECONTEXT_TAG
{
IMG_UINT64 ui64RobustnessAddress;
IMG_HANDLE hPrivData;
IMG_BYTE *pui8CompContextData;
IMG_BYTE *pui8FrameworkCmd;
IMG_INT32 i32Priority;
IMG_UINT32 ui32CompContextDataSize;
IMG_UINT32 ui32ContextFlags;
IMG_UINT32 ui32FrameworkCmdSize;
IMG_UINT32 ui32MaxDeadlineMS;
IMG_UINT32 ui32PackedCCBSizeU88;
} __packed PVRSRV_BRIDGE_IN_RGXCREATECOMPUTECONTEXT;
/* Bridge out structure for RGXCreateComputeContext */
typedef struct PVRSRV_BRIDGE_OUT_RGXCREATECOMPUTECONTEXT_TAG
{
IMG_HANDLE hComputeContext;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCREATECOMPUTECONTEXT;
/*******************************************
RGXDestroyComputeContext
*******************************************/
/* Bridge in structure for RGXDestroyComputeContext */
typedef struct PVRSRV_BRIDGE_IN_RGXDESTROYCOMPUTECONTEXT_TAG
{
IMG_HANDLE hComputeContext;
} __packed PVRSRV_BRIDGE_IN_RGXDESTROYCOMPUTECONTEXT;
/* Bridge out structure for RGXDestroyComputeContext */
typedef struct PVRSRV_BRIDGE_OUT_RGXDESTROYCOMPUTECONTEXT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXDESTROYCOMPUTECONTEXT;
/*******************************************
RGXFlushComputeData
*******************************************/
/* Bridge in structure for RGXFlushComputeData */
typedef struct PVRSRV_BRIDGE_IN_RGXFLUSHCOMPUTEDATA_TAG
{
IMG_HANDLE hComputeContext;
} __packed PVRSRV_BRIDGE_IN_RGXFLUSHCOMPUTEDATA;
/* Bridge out structure for RGXFlushComputeData */
typedef struct PVRSRV_BRIDGE_OUT_RGXFLUSHCOMPUTEDATA_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFLUSHCOMPUTEDATA;
/*******************************************
RGXSendCancelCmd
*******************************************/
/* Bridge in structure for RGXSendCancelCmd */
typedef struct PVRSRV_BRIDGE_IN_RGXSENDCANCELCMD_TAG
{
IMG_HANDLE hComputeContext;
IMG_INT32 i32FirstIntJobRefToCancel;
IMG_INT32 i32LastIntJobRefToCancel;
} __packed PVRSRV_BRIDGE_IN_RGXSENDCANCELCMD;
/* Bridge out structure for RGXSendCancelCmd */
typedef struct PVRSRV_BRIDGE_OUT_RGXSENDCANCELCMD_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXSENDCANCELCMD;
/*******************************************
RGXSetComputeContextPriority
*******************************************/
/* Bridge in structure for RGXSetComputeContextPriority */
typedef struct PVRSRV_BRIDGE_IN_RGXSETCOMPUTECONTEXTPRIORITY_TAG
{
IMG_HANDLE hComputeContext;
IMG_INT32 i32Priority;
} __packed PVRSRV_BRIDGE_IN_RGXSETCOMPUTECONTEXTPRIORITY;
/* Bridge out structure for RGXSetComputeContextPriority */
typedef struct PVRSRV_BRIDGE_OUT_RGXSETCOMPUTECONTEXTPRIORITY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXSETCOMPUTECONTEXTPRIORITY;
/*******************************************
RGXNotifyComputeWriteOffsetUpdate
*******************************************/
/* Bridge in structure for RGXNotifyComputeWriteOffsetUpdate */
typedef struct PVRSRV_BRIDGE_IN_RGXNOTIFYCOMPUTEWRITEOFFSETUPDATE_TAG
{
IMG_HANDLE hComputeContext;
} __packed PVRSRV_BRIDGE_IN_RGXNOTIFYCOMPUTEWRITEOFFSETUPDATE;
/* Bridge out structure for RGXNotifyComputeWriteOffsetUpdate */
typedef struct PVRSRV_BRIDGE_OUT_RGXNOTIFYCOMPUTEWRITEOFFSETUPDATE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXNOTIFYCOMPUTEWRITEOFFSETUPDATE;
/*******************************************
RGXGetLastDeviceError
*******************************************/
/* Bridge in structure for RGXGetLastDeviceError */
typedef struct PVRSRV_BRIDGE_IN_RGXGETLASTDEVICEERROR_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXGETLASTDEVICEERROR;
/* Bridge out structure for RGXGetLastDeviceError */
typedef struct PVRSRV_BRIDGE_OUT_RGXGETLASTDEVICEERROR_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32Error;
} __packed PVRSRV_BRIDGE_OUT_RGXGETLASTDEVICEERROR;
/*******************************************
RGXKickTimestampQuery
*******************************************/
/* Bridge in structure for RGXKickTimestampQuery */
typedef struct PVRSRV_BRIDGE_IN_RGXKICKTIMESTAMPQUERY_TAG
{
IMG_HANDLE hComputeContext;
IMG_BYTE *pui8DMCmd;
IMG_CHAR *puiUpdateFenceName;
PVRSRV_FENCE hCheckFenceFd;
PVRSRV_TIMELINE hUpdateTimeline;
IMG_UINT32 ui32CmdSize;
IMG_UINT32 ui32ExtJobRef;
} __packed PVRSRV_BRIDGE_IN_RGXKICKTIMESTAMPQUERY;
/* Bridge out structure for RGXKickTimestampQuery */
typedef struct PVRSRV_BRIDGE_OUT_RGXKICKTIMESTAMPQUERY_TAG
{
PVRSRV_ERROR eError;
PVRSRV_FENCE hUpdateFence;
} __packed PVRSRV_BRIDGE_OUT_RGXKICKTIMESTAMPQUERY;
/*******************************************
RGXKickCDM
*******************************************/
/* Bridge in structure for RGXKickCDM */
typedef struct PVRSRV_BRIDGE_IN_RGXKICKCDM_TAG
{
IMG_UINT64 ui64DeadlineInus;
IMG_HANDLE hComputeContext;
IMG_UINT32 *pui32ClientUpdateOffset;
IMG_UINT32 *pui32ClientUpdateValue;
IMG_UINT32 *pui32SyncPMRFlags;
IMG_BYTE *pui8DMCmd;
IMG_CHAR *puiUpdateFenceName;
IMG_HANDLE *phClientUpdateUFOSyncPrimBlock;
IMG_HANDLE *phSyncPMRs;
PVRSRV_FENCE hCheckFenceFd;
PVRSRV_FENCE hExportFenceToSignal;
PVRSRV_TIMELINE hUpdateTimeline;
IMG_UINT32 ui32ClientUpdateCount;
IMG_UINT32 ui32CmdSize;
IMG_UINT32 ui32ExtJobRef;
IMG_UINT32 ui32NumOfWorkgroups;
IMG_UINT32 ui32NumOfWorkitems;
IMG_UINT32 ui32PDumpFlags;
IMG_UINT32 ui32SyncPMRCount;
} __packed PVRSRV_BRIDGE_IN_RGXKICKCDM;
/* Bridge out structure for RGXKickCDM */
typedef struct PVRSRV_BRIDGE_OUT_RGXKICKCDM_TAG
{
PVRSRV_ERROR eError;
PVRSRV_FENCE hUpdateFence;
IMG_UINT32 ui32IntJobRef;
} __packed PVRSRV_BRIDGE_OUT_RGXKICKCDM;
/*******************************************
RGXCDMGetSharedMemory
*******************************************/
/* Bridge in structure for RGXCDMGetSharedMemory */
typedef struct PVRSRV_BRIDGE_IN_RGXCDMGETSHAREDMEMORY_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXCDMGETSHAREDMEMORY;
/* Bridge out structure for RGXCDMGetSharedMemory */
typedef struct PVRSRV_BRIDGE_OUT_RGXCDMGETSHAREDMEMORY_TAG
{
IMG_HANDLE hCLIPMRMem;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCDMGETSHAREDMEMORY;
/*******************************************
RGXCDMReleaseSharedMemory
*******************************************/
/* Bridge in structure for RGXCDMReleaseSharedMemory */
typedef struct PVRSRV_BRIDGE_IN_RGXCDMRELEASESHAREDMEMORY_TAG
{
IMG_HANDLE hPMRMem;
} __packed PVRSRV_BRIDGE_IN_RGXCDMRELEASESHAREDMEMORY;
/* Bridge out structure for RGXCDMReleaseSharedMemory */
typedef struct PVRSRV_BRIDGE_OUT_RGXCDMRELEASESHAREDMEMORY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCDMRELEASESHAREDMEMORY;
#endif /* COMMON_RGXCMP_BRIDGE_H */

View File

@@ -0,0 +1,339 @@
/*******************************************************************************
@File
@Title Common bridge header for rgxfwdbg
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for rgxfwdbg
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_RGXFWDBG_BRIDGE_H
#define COMMON_RGXFWDBG_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "devicemem_typedefs.h"
#include "rgx_bridge.h"
#include "pvrsrv_memallocflags.h"
#define PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST 0
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGSETFWLOG PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+0
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGDUMPFREELISTPAGELIST PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+1
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGPOWEROFF PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+2
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGPOWERON PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+3
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGSETVZCONNECTIONCOOLDOWNPERIODINSEC PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+4
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGSETHCSDEADLINE PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+5
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGSETDRIVERPRIORITY PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+6
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGSETDRIVERTIMESLICE PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+7
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGSETDRIVERTIMESLICEINTERVAL PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+8
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGSETDRIVERISOLATIONGROUP PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+9
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGSETOSNEWONLINESTATE PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+10
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGMAPGUESTHEAP PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+11
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGPHRCONFIGURE PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+12
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGWDGCONFIGURE PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+13
#define PVRSRV_BRIDGE_RGXFWDBG_RGXCURRENTTIME PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+14
#define PVRSRV_BRIDGE_RGXFWDBG_RGXFWDEBUGINJECTFAULT PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+15
#define PVRSRV_BRIDGE_RGXFWDBG_CMD_LAST (PVRSRV_BRIDGE_RGXFWDBG_CMD_FIRST+15)
/*******************************************
RGXFWDebugSetFWLog
*******************************************/
/* Bridge in structure for RGXFWDebugSetFWLog */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGSETFWLOG_TAG
{
IMG_UINT32 ui32RGXFWLogType;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGSETFWLOG;
/* Bridge out structure for RGXFWDebugSetFWLog */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETFWLOG_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETFWLOG;
/*******************************************
RGXFWDebugDumpFreelistPageList
*******************************************/
/* Bridge in structure for RGXFWDebugDumpFreelistPageList */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGDUMPFREELISTPAGELIST_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGDUMPFREELISTPAGELIST;
/* Bridge out structure for RGXFWDebugDumpFreelistPageList */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGDUMPFREELISTPAGELIST_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGDUMPFREELISTPAGELIST;
/*******************************************
RGXFWDebugPowerOff
*******************************************/
/* Bridge in structure for RGXFWDebugPowerOff */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGPOWEROFF_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGPOWEROFF;
/* Bridge out structure for RGXFWDebugPowerOff */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGPOWEROFF_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGPOWEROFF;
/*******************************************
RGXFWDebugPowerOn
*******************************************/
/* Bridge in structure for RGXFWDebugPowerOn */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGPOWERON_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGPOWERON;
/* Bridge out structure for RGXFWDebugPowerOn */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGPOWERON_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGPOWERON;
/*******************************************
RGXFWDebugSetVzConnectionCooldownPeriodInSec
*******************************************/
/* Bridge in structure for RGXFWDebugSetVzConnectionCooldownPeriodInSec */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGSETVZCONNECTIONCOOLDOWNPERIODINSEC_TAG
{
IMG_UINT32 ui32VzConnectionCooldownPeriodInSec;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGSETVZCONNECTIONCOOLDOWNPERIODINSEC;
/* Bridge out structure for RGXFWDebugSetVzConnectionCooldownPeriodInSec */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETVZCONNECTIONCOOLDOWNPERIODINSEC_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETVZCONNECTIONCOOLDOWNPERIODINSEC;
/*******************************************
RGXFWDebugSetHCSDeadline
*******************************************/
/* Bridge in structure for RGXFWDebugSetHCSDeadline */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGSETHCSDEADLINE_TAG
{
IMG_UINT32 ui32RGXHCSDeadline;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGSETHCSDEADLINE;
/* Bridge out structure for RGXFWDebugSetHCSDeadline */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETHCSDEADLINE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETHCSDEADLINE;
/*******************************************
RGXFWDebugSetDriverPriority
*******************************************/
/* Bridge in structure for RGXFWDebugSetDriverPriority */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGSETDRIVERPRIORITY_TAG
{
IMG_UINT32 ui32DriverID;
IMG_UINT32 ui32Priority;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGSETDRIVERPRIORITY;
/* Bridge out structure for RGXFWDebugSetDriverPriority */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETDRIVERPRIORITY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETDRIVERPRIORITY;
/*******************************************
RGXFWDebugSetDriverTimeSlice
*******************************************/
/* Bridge in structure for RGXFWDebugSetDriverTimeSlice */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGSETDRIVERTIMESLICE_TAG
{
IMG_UINT32 ui32DriverID;
IMG_UINT32 ui32TSPercentage;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGSETDRIVERTIMESLICE;
/* Bridge out structure for RGXFWDebugSetDriverTimeSlice */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETDRIVERTIMESLICE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETDRIVERTIMESLICE;
/*******************************************
RGXFWDebugSetDriverTimeSliceInterval
*******************************************/
/* Bridge in structure for RGXFWDebugSetDriverTimeSliceInterval */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGSETDRIVERTIMESLICEINTERVAL_TAG
{
IMG_UINT32 ui32TSIntervalMs;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGSETDRIVERTIMESLICEINTERVAL;
/* Bridge out structure for RGXFWDebugSetDriverTimeSliceInterval */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETDRIVERTIMESLICEINTERVAL_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETDRIVERTIMESLICEINTERVAL;
/*******************************************
RGXFWDebugSetDriverIsolationGroup
*******************************************/
/* Bridge in structure for RGXFWDebugSetDriverIsolationGroup */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGSETDRIVERISOLATIONGROUP_TAG
{
IMG_UINT32 ui32DriverID;
IMG_UINT32 ui32IsolationGroup;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGSETDRIVERISOLATIONGROUP;
/* Bridge out structure for RGXFWDebugSetDriverIsolationGroup */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETDRIVERISOLATIONGROUP_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETDRIVERISOLATIONGROUP;
/*******************************************
RGXFWDebugSetOSNewOnlineState
*******************************************/
/* Bridge in structure for RGXFWDebugSetOSNewOnlineState */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGSETOSNEWONLINESTATE_TAG
{
IMG_UINT32 ui32DriverID;
IMG_UINT32 ui32OSNewState;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGSETOSNEWONLINESTATE;
/* Bridge out structure for RGXFWDebugSetOSNewOnlineState */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETOSNEWONLINESTATE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGSETOSNEWONLINESTATE;
/*******************************************
RGXFWDebugMapGuestHeap
*******************************************/
/* Bridge in structure for RGXFWDebugMapGuestHeap */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGMAPGUESTHEAP_TAG
{
IMG_UINT64 ui64ui64GuestHeapBase;
IMG_UINT32 ui32DriverID;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGMAPGUESTHEAP;
/* Bridge out structure for RGXFWDebugMapGuestHeap */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGMAPGUESTHEAP_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGMAPGUESTHEAP;
/*******************************************
RGXFWDebugPHRConfigure
*******************************************/
/* Bridge in structure for RGXFWDebugPHRConfigure */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGPHRCONFIGURE_TAG
{
IMG_UINT32 ui32ui32PHRMode;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGPHRCONFIGURE;
/* Bridge out structure for RGXFWDebugPHRConfigure */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGPHRCONFIGURE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGPHRCONFIGURE;
/*******************************************
RGXFWDebugWdgConfigure
*******************************************/
/* Bridge in structure for RGXFWDebugWdgConfigure */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGWDGCONFIGURE_TAG
{
IMG_UINT32 ui32ui32WdgPeriodUs;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGWDGCONFIGURE;
/* Bridge out structure for RGXFWDebugWdgConfigure */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGWDGCONFIGURE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGWDGCONFIGURE;
/*******************************************
RGXCurrentTime
*******************************************/
/* Bridge in structure for RGXCurrentTime */
typedef struct PVRSRV_BRIDGE_IN_RGXCURRENTTIME_TAG
{
IMG_UINT8 ui8TimerType;
} __packed PVRSRV_BRIDGE_IN_RGXCURRENTTIME;
/* Bridge out structure for RGXCurrentTime */
typedef struct PVRSRV_BRIDGE_OUT_RGXCURRENTTIME_TAG
{
IMG_UINT64 ui64Time;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCURRENTTIME;
/*******************************************
RGXFWDebugInjectFault
*******************************************/
/* Bridge in structure for RGXFWDebugInjectFault */
typedef struct PVRSRV_BRIDGE_IN_RGXFWDEBUGINJECTFAULT_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXFWDEBUGINJECTFAULT;
/* Bridge out structure for RGXFWDebugInjectFault */
typedef struct PVRSRV_BRIDGE_OUT_RGXFWDEBUGINJECTFAULT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXFWDEBUGINJECTFAULT;
#endif /* COMMON_RGXFWDBG_BRIDGE_H */

View File

@@ -0,0 +1,302 @@
/*******************************************************************************
@File
@Title Common bridge header for rgxhwperf
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for rgxhwperf
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_RGXHWPERF_BRIDGE_H
#define COMMON_RGXHWPERF_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "rgx_bridge.h"
#include "rgx_hwperf.h"
#define PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST 0
#define PVRSRV_BRIDGE_RGXHWPERF_RGXGETCONFIGUREDHWPERFCOUNTERS PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+0
#define PVRSRV_BRIDGE_RGXHWPERF_RGXGETENABLEDHWPERFBLOCKS PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+1
#define PVRSRV_BRIDGE_RGXHWPERF_RGXGETHWPERFTIMESTAMP PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+2
#define PVRSRV_BRIDGE_RGXHWPERF_RGXCTRLHWPERF PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+3
#define PVRSRV_BRIDGE_RGXHWPERF_RGXGETHWPERFBVNCFEATUREFLAGS PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+4
#define PVRSRV_BRIDGE_RGXHWPERF_RGXCONTROLHWPERFBLOCKS PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+5
#define PVRSRV_BRIDGE_RGXHWPERF_RGXOPENHWPERFCLIENTSTREAM PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+6
#define PVRSRV_BRIDGE_RGXHWPERF_RGXCLOSEHWPERFCLIENTSTREAM PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+7
#define PVRSRV_BRIDGE_RGXHWPERF_RGXWRITEHWPERFCLIENTEVENT PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+8
#define PVRSRV_BRIDGE_RGXHWPERF_RGXCONFIGMUXHWPERFCOUNTERS PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+9
#define PVRSRV_BRIDGE_RGXHWPERF_RGXCONFIGCUSTOMCOUNTERS PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+10
#define PVRSRV_BRIDGE_RGXHWPERF_RGXCONFIGUREHWPERFBLOCKS PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+11
#define PVRSRV_BRIDGE_RGXHWPERF_RGXGETCONFIGUREDHWPERFMUXCOUNTERS PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+12
#define PVRSRV_BRIDGE_RGXHWPERF_CMD_LAST (PVRSRV_BRIDGE_RGXHWPERF_CMD_FIRST+12)
/*******************************************
RGXGetConfiguredHWPerfCounters
*******************************************/
/* Bridge in structure for RGXGetConfiguredHWPerfCounters */
typedef struct PVRSRV_BRIDGE_IN_RGXGETCONFIGUREDHWPERFCOUNTERS_TAG
{
RGX_HWPERF_CONFIG_CNTBLK *psConfiguredCounters;
IMG_UINT32 ui32BlockID;
} __packed PVRSRV_BRIDGE_IN_RGXGETCONFIGUREDHWPERFCOUNTERS;
/* Bridge out structure for RGXGetConfiguredHWPerfCounters */
typedef struct PVRSRV_BRIDGE_OUT_RGXGETCONFIGUREDHWPERFCOUNTERS_TAG
{
RGX_HWPERF_CONFIG_CNTBLK *psConfiguredCounters;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXGETCONFIGUREDHWPERFCOUNTERS;
/*******************************************
RGXGetEnabledHWPerfBlocks
*******************************************/
/* Bridge in structure for RGXGetEnabledHWPerfBlocks */
typedef struct PVRSRV_BRIDGE_IN_RGXGETENABLEDHWPERFBLOCKS_TAG
{
IMG_UINT32 *pui32EnabledBlockIDs;
IMG_UINT32 ui32ArrayLen;
} __packed PVRSRV_BRIDGE_IN_RGXGETENABLEDHWPERFBLOCKS;
/* Bridge out structure for RGXGetEnabledHWPerfBlocks */
typedef struct PVRSRV_BRIDGE_OUT_RGXGETENABLEDHWPERFBLOCKS_TAG
{
IMG_UINT32 *pui32EnabledBlockIDs;
PVRSRV_ERROR eError;
IMG_UINT32 ui32BlockCount;
} __packed PVRSRV_BRIDGE_OUT_RGXGETENABLEDHWPERFBLOCKS;
/*******************************************
RGXGetHWPerfTimeStamp
*******************************************/
/* Bridge in structure for RGXGetHWPerfTimeStamp */
typedef struct PVRSRV_BRIDGE_IN_RGXGETHWPERFTIMESTAMP_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXGETHWPERFTIMESTAMP;
/* Bridge out structure for RGXGetHWPerfTimeStamp */
typedef struct PVRSRV_BRIDGE_OUT_RGXGETHWPERFTIMESTAMP_TAG
{
IMG_UINT64 ui64TimeStamp;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXGETHWPERFTIMESTAMP;
/*******************************************
RGXCtrlHWPerf
*******************************************/
/* Bridge in structure for RGXCtrlHWPerf */
typedef struct PVRSRV_BRIDGE_IN_RGXCTRLHWPERF_TAG
{
IMG_UINT64 ui64Mask;
IMG_UINT32 ui32StreamId;
IMG_BOOL bToggle;
} __packed PVRSRV_BRIDGE_IN_RGXCTRLHWPERF;
/* Bridge out structure for RGXCtrlHWPerf */
typedef struct PVRSRV_BRIDGE_OUT_RGXCTRLHWPERF_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCTRLHWPERF;
/*******************************************
RGXGetHWPerfBvncFeatureFlags
*******************************************/
/* Bridge in structure for RGXGetHWPerfBvncFeatureFlags */
typedef struct PVRSRV_BRIDGE_IN_RGXGETHWPERFBVNCFEATUREFLAGS_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXGETHWPERFBVNCFEATUREFLAGS;
/* Bridge out structure for RGXGetHWPerfBvncFeatureFlags */
typedef struct PVRSRV_BRIDGE_OUT_RGXGETHWPERFBVNCFEATUREFLAGS_TAG
{
RGX_HWPERF_BVNC sBVNC;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXGETHWPERFBVNCFEATUREFLAGS;
/*******************************************
RGXControlHWPerfBlocks
*******************************************/
/* Bridge in structure for RGXControlHWPerfBlocks */
typedef struct PVRSRV_BRIDGE_IN_RGXCONTROLHWPERFBLOCKS_TAG
{
IMG_UINT16 *pui16BlockIDs;
IMG_UINT32 ui32ArrayLen;
IMG_BOOL bEnable;
} __packed PVRSRV_BRIDGE_IN_RGXCONTROLHWPERFBLOCKS;
/* Bridge out structure for RGXControlHWPerfBlocks */
typedef struct PVRSRV_BRIDGE_OUT_RGXCONTROLHWPERFBLOCKS_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCONTROLHWPERFBLOCKS;
/*******************************************
RGXOpenHWPerfClientStream
*******************************************/
/* Bridge in structure for RGXOpenHWPerfClientStream */
typedef struct PVRSRV_BRIDGE_IN_RGXOPENHWPERFCLIENTSTREAM_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXOPENHWPERFCLIENTSTREAM;
/* Bridge out structure for RGXOpenHWPerfClientStream */
typedef struct PVRSRV_BRIDGE_OUT_RGXOPENHWPERFCLIENTSTREAM_TAG
{
IMG_HANDLE hSD;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXOPENHWPERFCLIENTSTREAM;
/*******************************************
RGXCloseHWPerfClientStream
*******************************************/
/* Bridge in structure for RGXCloseHWPerfClientStream */
typedef struct PVRSRV_BRIDGE_IN_RGXCLOSEHWPERFCLIENTSTREAM_TAG
{
IMG_HANDLE hSD;
} __packed PVRSRV_BRIDGE_IN_RGXCLOSEHWPERFCLIENTSTREAM;
/* Bridge out structure for RGXCloseHWPerfClientStream */
typedef struct PVRSRV_BRIDGE_OUT_RGXCLOSEHWPERFCLIENTSTREAM_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCLOSEHWPERFCLIENTSTREAM;
/*******************************************
RGXWriteHWPerfClientEvent
*******************************************/
/* Bridge in structure for RGXWriteHWPerfClientEvent */
typedef struct PVRSRV_BRIDGE_IN_RGXWRITEHWPERFCLIENTEVENT_TAG
{
IMG_HANDLE hSD;
IMG_BYTE *pui8Data;
IMG_UINT32 ui32Size;
} __packed PVRSRV_BRIDGE_IN_RGXWRITEHWPERFCLIENTEVENT;
/* Bridge out structure for RGXWriteHWPerfClientEvent */
typedef struct PVRSRV_BRIDGE_OUT_RGXWRITEHWPERFCLIENTEVENT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXWRITEHWPERFCLIENTEVENT;
/*******************************************
RGXConfigMuxHWPerfCounters
*******************************************/
/* Bridge in structure for RGXConfigMuxHWPerfCounters */
typedef struct PVRSRV_BRIDGE_IN_RGXCONFIGMUXHWPERFCOUNTERS_TAG
{
RGX_HWPERF_CONFIG_MUX_CNTBLK *psBlockConfigs;
IMG_UINT32 ui32ArrayLen;
} __packed PVRSRV_BRIDGE_IN_RGXCONFIGMUXHWPERFCOUNTERS;
/* Bridge out structure for RGXConfigMuxHWPerfCounters */
typedef struct PVRSRV_BRIDGE_OUT_RGXCONFIGMUXHWPERFCOUNTERS_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCONFIGMUXHWPERFCOUNTERS;
/*******************************************
RGXConfigCustomCounters
*******************************************/
/* Bridge in structure for RGXConfigCustomCounters */
typedef struct PVRSRV_BRIDGE_IN_RGXCONFIGCUSTOMCOUNTERS_TAG
{
IMG_UINT32 *pui32CustomCounterIDs;
IMG_UINT16 ui16CustomBlockID;
IMG_UINT16 ui16NumCustomCounters;
} __packed PVRSRV_BRIDGE_IN_RGXCONFIGCUSTOMCOUNTERS;
/* Bridge out structure for RGXConfigCustomCounters */
typedef struct PVRSRV_BRIDGE_OUT_RGXCONFIGCUSTOMCOUNTERS_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCONFIGCUSTOMCOUNTERS;
/*******************************************
RGXConfigureHWPerfBlocks
*******************************************/
/* Bridge in structure for RGXConfigureHWPerfBlocks */
typedef struct PVRSRV_BRIDGE_IN_RGXCONFIGUREHWPERFBLOCKS_TAG
{
RGX_HWPERF_CONFIG_CNTBLK *psBlockConfigs;
IMG_UINT32 ui32ArrayLen;
IMG_UINT32 ui32CtrlWord;
} __packed PVRSRV_BRIDGE_IN_RGXCONFIGUREHWPERFBLOCKS;
/* Bridge out structure for RGXConfigureHWPerfBlocks */
typedef struct PVRSRV_BRIDGE_OUT_RGXCONFIGUREHWPERFBLOCKS_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCONFIGUREHWPERFBLOCKS;
/*******************************************
RGXGetConfiguredHWPerfMuxCounters
*******************************************/
/* Bridge in structure for RGXGetConfiguredHWPerfMuxCounters */
typedef struct PVRSRV_BRIDGE_IN_RGXGETCONFIGUREDHWPERFMUXCOUNTERS_TAG
{
RGX_HWPERF_CONFIG_MUX_CNTBLK *psConfiguredMuxCounters;
IMG_UINT32 ui32BlockID;
} __packed PVRSRV_BRIDGE_IN_RGXGETCONFIGUREDHWPERFMUXCOUNTERS;
/* Bridge out structure for RGXGetConfiguredHWPerfMuxCounters */
typedef struct PVRSRV_BRIDGE_OUT_RGXGETCONFIGUREDHWPERFMUXCOUNTERS_TAG
{
RGX_HWPERF_CONFIG_MUX_CNTBLK *psConfiguredMuxCounters;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXGETCONFIGUREDHWPERFMUXCOUNTERS;
#endif /* COMMON_RGXHWPERF_BRIDGE_H */

View File

@@ -0,0 +1,124 @@
/*******************************************************************************
@File
@Title Common bridge header for rgxkicksync
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for rgxkicksync
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_RGXKICKSYNC_BRIDGE_H
#define COMMON_RGXKICKSYNC_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "rgx_bridge.h"
#include "pvrsrv_sync_km.h"
#define PVRSRV_BRIDGE_RGXKICKSYNC_CMD_FIRST 0
#define PVRSRV_BRIDGE_RGXKICKSYNC_RGXCREATEKICKSYNCCONTEXT PVRSRV_BRIDGE_RGXKICKSYNC_CMD_FIRST+0
#define PVRSRV_BRIDGE_RGXKICKSYNC_RGXDESTROYKICKSYNCCONTEXT PVRSRV_BRIDGE_RGXKICKSYNC_CMD_FIRST+1
#define PVRSRV_BRIDGE_RGXKICKSYNC_RGXKICKSYNC2 PVRSRV_BRIDGE_RGXKICKSYNC_CMD_FIRST+2
#define PVRSRV_BRIDGE_RGXKICKSYNC_CMD_LAST (PVRSRV_BRIDGE_RGXKICKSYNC_CMD_FIRST+2)
/*******************************************
RGXCreateKickSyncContext
*******************************************/
/* Bridge in structure for RGXCreateKickSyncContext */
typedef struct PVRSRV_BRIDGE_IN_RGXCREATEKICKSYNCCONTEXT_TAG
{
IMG_HANDLE hPrivData;
IMG_UINT32 ui32ContextFlags;
IMG_UINT32 ui32PackedCCBSizeU88;
} __packed PVRSRV_BRIDGE_IN_RGXCREATEKICKSYNCCONTEXT;
/* Bridge out structure for RGXCreateKickSyncContext */
typedef struct PVRSRV_BRIDGE_OUT_RGXCREATEKICKSYNCCONTEXT_TAG
{
IMG_HANDLE hKickSyncContext;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCREATEKICKSYNCCONTEXT;
/*******************************************
RGXDestroyKickSyncContext
*******************************************/
/* Bridge in structure for RGXDestroyKickSyncContext */
typedef struct PVRSRV_BRIDGE_IN_RGXDESTROYKICKSYNCCONTEXT_TAG
{
IMG_HANDLE hKickSyncContext;
} __packed PVRSRV_BRIDGE_IN_RGXDESTROYKICKSYNCCONTEXT;
/* Bridge out structure for RGXDestroyKickSyncContext */
typedef struct PVRSRV_BRIDGE_OUT_RGXDESTROYKICKSYNCCONTEXT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXDESTROYKICKSYNCCONTEXT;
/*******************************************
RGXKickSync2
*******************************************/
/* Bridge in structure for RGXKickSync2 */
typedef struct PVRSRV_BRIDGE_IN_RGXKICKSYNC2_TAG
{
IMG_HANDLE hKickSyncContext;
IMG_UINT32 *pui32UpdateDevVarOffset;
IMG_UINT32 *pui32UpdateValue;
IMG_CHAR *puiUpdateFenceName;
IMG_HANDLE *phUpdateUFODevVarBlock;
PVRSRV_FENCE hCheckFenceFD;
PVRSRV_TIMELINE hTimelineFenceFD;
IMG_UINT32 ui32ClientUpdateCount;
IMG_UINT32 ui32ExtJobRef;
IMG_UINT32 ui32FWCmdSize;
} __packed PVRSRV_BRIDGE_IN_RGXKICKSYNC2;
/* Bridge out structure for RGXKickSync2 */
typedef struct PVRSRV_BRIDGE_OUT_RGXKICKSYNC2_TAG
{
PVRSRV_ERROR eError;
PVRSRV_FENCE hUpdateFenceFD;
} __packed PVRSRV_BRIDGE_OUT_RGXKICKSYNC2;
#endif /* COMMON_RGXKICKSYNC_BRIDGE_H */

View File

@@ -0,0 +1,146 @@
/*******************************************************************************
@File
@Title Common bridge header for rgxregconfig
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for rgxregconfig
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_RGXREGCONFIG_BRIDGE_H
#define COMMON_RGXREGCONFIG_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "rgx_bridge.h"
#define PVRSRV_BRIDGE_RGXREGCONFIG_CMD_FIRST 0
#define PVRSRV_BRIDGE_RGXREGCONFIG_RGXSETREGCONFIGTYPE PVRSRV_BRIDGE_RGXREGCONFIG_CMD_FIRST+0
#define PVRSRV_BRIDGE_RGXREGCONFIG_RGXADDREGCONFIG PVRSRV_BRIDGE_RGXREGCONFIG_CMD_FIRST+1
#define PVRSRV_BRIDGE_RGXREGCONFIG_RGXCLEARREGCONFIG PVRSRV_BRIDGE_RGXREGCONFIG_CMD_FIRST+2
#define PVRSRV_BRIDGE_RGXREGCONFIG_RGXENABLEREGCONFIG PVRSRV_BRIDGE_RGXREGCONFIG_CMD_FIRST+3
#define PVRSRV_BRIDGE_RGXREGCONFIG_RGXDISABLEREGCONFIG PVRSRV_BRIDGE_RGXREGCONFIG_CMD_FIRST+4
#define PVRSRV_BRIDGE_RGXREGCONFIG_CMD_LAST (PVRSRV_BRIDGE_RGXREGCONFIG_CMD_FIRST+4)
/*******************************************
RGXSetRegConfigType
*******************************************/
/* Bridge in structure for RGXSetRegConfigType */
typedef struct PVRSRV_BRIDGE_IN_RGXSETREGCONFIGTYPE_TAG
{
IMG_UINT8 ui8RegPowerIsland;
} __packed PVRSRV_BRIDGE_IN_RGXSETREGCONFIGTYPE;
/* Bridge out structure for RGXSetRegConfigType */
typedef struct PVRSRV_BRIDGE_OUT_RGXSETREGCONFIGTYPE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXSETREGCONFIGTYPE;
/*******************************************
RGXAddRegconfig
*******************************************/
/* Bridge in structure for RGXAddRegconfig */
typedef struct PVRSRV_BRIDGE_IN_RGXADDREGCONFIG_TAG
{
IMG_UINT64 ui64RegMask;
IMG_UINT64 ui64RegValue;
IMG_UINT32 ui32RegAddr;
} __packed PVRSRV_BRIDGE_IN_RGXADDREGCONFIG;
/* Bridge out structure for RGXAddRegconfig */
typedef struct PVRSRV_BRIDGE_OUT_RGXADDREGCONFIG_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXADDREGCONFIG;
/*******************************************
RGXClearRegConfig
*******************************************/
/* Bridge in structure for RGXClearRegConfig */
typedef struct PVRSRV_BRIDGE_IN_RGXCLEARREGCONFIG_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXCLEARREGCONFIG;
/* Bridge out structure for RGXClearRegConfig */
typedef struct PVRSRV_BRIDGE_OUT_RGXCLEARREGCONFIG_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCLEARREGCONFIG;
/*******************************************
RGXEnableRegConfig
*******************************************/
/* Bridge in structure for RGXEnableRegConfig */
typedef struct PVRSRV_BRIDGE_IN_RGXENABLEREGCONFIG_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXENABLEREGCONFIG;
/* Bridge out structure for RGXEnableRegConfig */
typedef struct PVRSRV_BRIDGE_OUT_RGXENABLEREGCONFIG_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXENABLEREGCONFIG;
/*******************************************
RGXDisableRegConfig
*******************************************/
/* Bridge in structure for RGXDisableRegConfig */
typedef struct PVRSRV_BRIDGE_IN_RGXDISABLEREGCONFIG_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXDISABLEREGCONFIG;
/* Bridge out structure for RGXDisableRegConfig */
typedef struct PVRSRV_BRIDGE_OUT_RGXDISABLEREGCONFIG_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXDISABLEREGCONFIG;
#endif /* COMMON_RGXREGCONFIG_BRIDGE_H */

View File

@@ -0,0 +1,404 @@
/*******************************************************************************
@File
@Title Common bridge header for rgxta3d
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for rgxta3d
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_RGXTA3D_BRIDGE_H
#define COMMON_RGXTA3D_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "rgx_bridge.h"
#include "rgx_fwif_shared.h"
#include "devicemem_typedefs.h"
#include "pvrsrv_sync_km.h"
#define PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST 0
#define PVRSRV_BRIDGE_RGXTA3D_RGXDESTROYHWRTDATASET PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+0
#define PVRSRV_BRIDGE_RGXTA3D_RGXCREATEZSBUFFER PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+1
#define PVRSRV_BRIDGE_RGXTA3D_RGXDESTROYZSBUFFER PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+2
#define PVRSRV_BRIDGE_RGXTA3D_RGXPOPULATEZSBUFFER PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+3
#define PVRSRV_BRIDGE_RGXTA3D_RGXUNPOPULATEZSBUFFER PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+4
#define PVRSRV_BRIDGE_RGXTA3D_RGXDESTROYFREELIST PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+5
#define PVRSRV_BRIDGE_RGXTA3D_RGXDESTROYRENDERCONTEXT PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+6
#define PVRSRV_BRIDGE_RGXTA3D_RGXSENDZSSTOREDISABLE PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+7
#define PVRSRV_BRIDGE_RGXTA3D_RGXSETRENDERCONTEXTPRIORITY PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+8
#define PVRSRV_BRIDGE_RGXTA3D_RGXRENDERCONTEXTSTALLED PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+9
#define PVRSRV_BRIDGE_RGXTA3D_RGXKICKTA3D2 PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+10
#define PVRSRV_BRIDGE_RGXTA3D_RGXCREATEHWRTDATASET PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+11
#define PVRSRV_BRIDGE_RGXTA3D_RGXCREATEFREELIST PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+12
#define PVRSRV_BRIDGE_RGXTA3D_RGXCREATERENDERCONTEXT PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+13
#define PVRSRV_BRIDGE_RGXTA3D_CMD_LAST (PVRSRV_BRIDGE_RGXTA3D_CMD_FIRST+13)
/*******************************************
RGXDestroyHWRTDataSet
*******************************************/
/* Bridge in structure for RGXDestroyHWRTDataSet */
typedef struct PVRSRV_BRIDGE_IN_RGXDESTROYHWRTDATASET_TAG
{
IMG_HANDLE hKmHwRTDataSet;
} __packed PVRSRV_BRIDGE_IN_RGXDESTROYHWRTDATASET;
/* Bridge out structure for RGXDestroyHWRTDataSet */
typedef struct PVRSRV_BRIDGE_OUT_RGXDESTROYHWRTDATASET_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXDESTROYHWRTDATASET;
/*******************************************
RGXCreateZSBuffer
*******************************************/
/* Bridge in structure for RGXCreateZSBuffer */
typedef struct PVRSRV_BRIDGE_IN_RGXCREATEZSBUFFER_TAG
{
IMG_HANDLE hPMR;
IMG_HANDLE hReservation;
PVRSRV_MEMALLOCFLAGS_T uiMapFlags;
} __packed PVRSRV_BRIDGE_IN_RGXCREATEZSBUFFER;
/* Bridge out structure for RGXCreateZSBuffer */
typedef struct PVRSRV_BRIDGE_OUT_RGXCREATEZSBUFFER_TAG
{
IMG_HANDLE hsZSBufferKM;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCREATEZSBUFFER;
/*******************************************
RGXDestroyZSBuffer
*******************************************/
/* Bridge in structure for RGXDestroyZSBuffer */
typedef struct PVRSRV_BRIDGE_IN_RGXDESTROYZSBUFFER_TAG
{
IMG_HANDLE hsZSBufferMemDesc;
} __packed PVRSRV_BRIDGE_IN_RGXDESTROYZSBUFFER;
/* Bridge out structure for RGXDestroyZSBuffer */
typedef struct PVRSRV_BRIDGE_OUT_RGXDESTROYZSBUFFER_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXDESTROYZSBUFFER;
/*******************************************
RGXPopulateZSBuffer
*******************************************/
/* Bridge in structure for RGXPopulateZSBuffer */
typedef struct PVRSRV_BRIDGE_IN_RGXPOPULATEZSBUFFER_TAG
{
IMG_HANDLE hsZSBufferKM;
} __packed PVRSRV_BRIDGE_IN_RGXPOPULATEZSBUFFER;
/* Bridge out structure for RGXPopulateZSBuffer */
typedef struct PVRSRV_BRIDGE_OUT_RGXPOPULATEZSBUFFER_TAG
{
IMG_HANDLE hsPopulation;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXPOPULATEZSBUFFER;
/*******************************************
RGXUnpopulateZSBuffer
*******************************************/
/* Bridge in structure for RGXUnpopulateZSBuffer */
typedef struct PVRSRV_BRIDGE_IN_RGXUNPOPULATEZSBUFFER_TAG
{
IMG_HANDLE hsPopulation;
} __packed PVRSRV_BRIDGE_IN_RGXUNPOPULATEZSBUFFER;
/* Bridge out structure for RGXUnpopulateZSBuffer */
typedef struct PVRSRV_BRIDGE_OUT_RGXUNPOPULATEZSBUFFER_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXUNPOPULATEZSBUFFER;
/*******************************************
RGXDestroyFreeList
*******************************************/
/* Bridge in structure for RGXDestroyFreeList */
typedef struct PVRSRV_BRIDGE_IN_RGXDESTROYFREELIST_TAG
{
IMG_HANDLE hCleanupCookie;
} __packed PVRSRV_BRIDGE_IN_RGXDESTROYFREELIST;
/* Bridge out structure for RGXDestroyFreeList */
typedef struct PVRSRV_BRIDGE_OUT_RGXDESTROYFREELIST_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXDESTROYFREELIST;
/*******************************************
RGXDestroyRenderContext
*******************************************/
/* Bridge in structure for RGXDestroyRenderContext */
typedef struct PVRSRV_BRIDGE_IN_RGXDESTROYRENDERCONTEXT_TAG
{
IMG_HANDLE hCleanupCookie;
} __packed PVRSRV_BRIDGE_IN_RGXDESTROYRENDERCONTEXT;
/* Bridge out structure for RGXDestroyRenderContext */
typedef struct PVRSRV_BRIDGE_OUT_RGXDESTROYRENDERCONTEXT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXDESTROYRENDERCONTEXT;
/*******************************************
RGXSendZSStoreDisable
*******************************************/
/* Bridge in structure for RGXSendZSStoreDisable */
typedef struct PVRSRV_BRIDGE_IN_RGXSENDZSSTOREDISABLE_TAG
{
IMG_HANDLE hRenderContext;
IMG_INT32 i32ExtJobRefToDisableZSStore;
IMG_BOOL bDisableDepthStore;
IMG_BOOL bDisableStencilStore;
} __packed PVRSRV_BRIDGE_IN_RGXSENDZSSTOREDISABLE;
/* Bridge out structure for RGXSendZSStoreDisable */
typedef struct PVRSRV_BRIDGE_OUT_RGXSENDZSSTOREDISABLE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXSENDZSSTOREDISABLE;
/*******************************************
RGXSetRenderContextPriority
*******************************************/
/* Bridge in structure for RGXSetRenderContextPriority */
typedef struct PVRSRV_BRIDGE_IN_RGXSETRENDERCONTEXTPRIORITY_TAG
{
IMG_HANDLE hRenderContext;
IMG_INT32 i32Priority;
} __packed PVRSRV_BRIDGE_IN_RGXSETRENDERCONTEXTPRIORITY;
/* Bridge out structure for RGXSetRenderContextPriority */
typedef struct PVRSRV_BRIDGE_OUT_RGXSETRENDERCONTEXTPRIORITY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXSETRENDERCONTEXTPRIORITY;
/*******************************************
RGXRenderContextStalled
*******************************************/
/* Bridge in structure for RGXRenderContextStalled */
typedef struct PVRSRV_BRIDGE_IN_RGXRENDERCONTEXTSTALLED_TAG
{
IMG_HANDLE hRenderContext;
} __packed PVRSRV_BRIDGE_IN_RGXRENDERCONTEXTSTALLED;
/* Bridge out structure for RGXRenderContextStalled */
typedef struct PVRSRV_BRIDGE_OUT_RGXRENDERCONTEXTSTALLED_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXRENDERCONTEXTSTALLED;
/*******************************************
RGXKickTA3D2
*******************************************/
/* Bridge in structure for RGXKickTA3D2 */
typedef struct PVRSRV_BRIDGE_IN_RGXKICKTA3D2_TAG
{
IMG_UINT64 ui64Deadline;
IMG_HANDLE hKMHWRTDataSet;
IMG_HANDLE hMSAAScratchBuffer;
IMG_HANDLE hPRFenceUFOSyncPrimBlock;
IMG_HANDLE hRenderContext;
IMG_HANDLE hZSBuffer;
IMG_UINT32 *pui32Client3DUpdateSyncOffset;
IMG_UINT32 *pui32Client3DUpdateValue;
IMG_UINT32 *pui32ClientTAFenceSyncOffset;
IMG_UINT32 *pui32ClientTAFenceValue;
IMG_UINT32 *pui32ClientTAUpdateSyncOffset;
IMG_UINT32 *pui32ClientTAUpdateValue;
IMG_UINT32 *pui32SyncPMRFlags;
IMG_BYTE *pui83DCmd;
IMG_BYTE *pui83DPRCmd;
IMG_BYTE *pui8TACmd;
IMG_CHAR *puiUpdateFenceName;
IMG_CHAR *puiUpdateFenceName3D;
IMG_HANDLE *phClient3DUpdateSyncPrimBlock;
IMG_HANDLE *phClientTAFenceSyncPrimBlock;
IMG_HANDLE *phClientTAUpdateSyncPrimBlock;
IMG_HANDLE *phSyncPMRs;
PVRSRV_FENCE hCheckFence;
PVRSRV_FENCE hCheckFence3D;
PVRSRV_TIMELINE hUpdateTimeline;
PVRSRV_TIMELINE hUpdateTimeline3D;
IMG_UINT32 ui323DCmdSize;
IMG_UINT32 ui323DPRCmdSize;
IMG_UINT32 ui32Client3DUpdateCount;
IMG_UINT32 ui32ClientTAFenceCount;
IMG_UINT32 ui32ClientTAUpdateCount;
IMG_UINT32 ui32ExtJobRef;
IMG_UINT32 ui32NumberOfDrawCalls;
IMG_UINT32 ui32NumberOfIndices;
IMG_UINT32 ui32NumberOfMRTs;
IMG_UINT32 ui32PDumpFlags;
IMG_UINT32 ui32PRFenceUFOSyncOffset;
IMG_UINT32 ui32PRFenceValue;
IMG_UINT32 ui32RenderTargetSize;
IMG_UINT32 ui32SyncPMRCount;
IMG_UINT32 ui32TACmdSize;
IMG_BOOL bbAbort;
IMG_BOOL bbKick3D;
IMG_BOOL bbKickPR;
IMG_BOOL bbKickTA;
} __packed PVRSRV_BRIDGE_IN_RGXKICKTA3D2;
/* Bridge out structure for RGXKickTA3D2 */
typedef struct PVRSRV_BRIDGE_OUT_RGXKICKTA3D2_TAG
{
PVRSRV_ERROR eError;
PVRSRV_FENCE hUpdateFence;
PVRSRV_FENCE hUpdateFence3D;
} __packed PVRSRV_BRIDGE_OUT_RGXKICKTA3D2;
/*******************************************
RGXCreateHWRTDataSet
*******************************************/
/* Bridge in structure for RGXCreateHWRTDataSet */
typedef struct PVRSRV_BRIDGE_IN_RGXCREATEHWRTDATASET_TAG
{
IMG_UINT64 ui64FlippedMultiSampleCtl;
IMG_UINT64 ui64MultiSampleCtl;
IMG_HANDLE hPMMlistsReservation;
IMG_DEV_VIRTADDR *psMacrotileArrayDevVAddr;
IMG_DEV_VIRTADDR *psRTCDevVAddr;
IMG_DEV_VIRTADDR *psRgnHeaderDevVAddr;
IMG_DEV_VIRTADDR *psTailPtrsDevVAddr;
IMG_DEV_VIRTADDR *psVHeapTableDevVAddr;
IMG_HANDLE *phKmHwRTDataSet;
IMG_HANDLE *phapsFreeLists;
IMG_UINT32 ui32ISPMergeLowerX;
IMG_UINT32 ui32ISPMergeLowerY;
IMG_UINT32 ui32ISPMergeScaleX;
IMG_UINT32 ui32ISPMergeScaleY;
IMG_UINT32 ui32ISPMergeUpperX;
IMG_UINT32 ui32ISPMergeUpperY;
IMG_UINT32 ui32ISPMtileSize;
IMG_UINT32 ui32MTileStride;
IMG_UINT32 ui32PPPScreen;
IMG_UINT32 ui32RgnHeaderSize;
IMG_UINT32 ui32TEAA;
IMG_UINT32 ui32TEMTILE1;
IMG_UINT32 ui32TEMTILE2;
IMG_UINT32 ui32TEScreen;
IMG_UINT32 ui32TPCSize;
IMG_UINT32 ui32TPCStride;
IMG_UINT16 ui16MaxRTs;
} __packed PVRSRV_BRIDGE_IN_RGXCREATEHWRTDATASET;
/* Bridge out structure for RGXCreateHWRTDataSet */
typedef struct PVRSRV_BRIDGE_OUT_RGXCREATEHWRTDATASET_TAG
{
IMG_HANDLE *phKmHwRTDataSet;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCREATEHWRTDATASET;
/*******************************************
RGXCreateFreeList
*******************************************/
/* Bridge in structure for RGXCreateFreeList */
typedef struct PVRSRV_BRIDGE_IN_RGXCREATEFREELIST_TAG
{
IMG_HANDLE hFreeListReservation;
IMG_HANDLE hMemCtxPrivData;
IMG_HANDLE hsGlobalFreeList;
IMG_UINT32 ui32GrowFLPages;
IMG_UINT32 ui32GrowParamThreshold;
IMG_UINT32 ui32InitFLPages;
IMG_UINT32 ui32MaxFLPages;
IMG_BOOL bbFreeListCheck;
} __packed PVRSRV_BRIDGE_IN_RGXCREATEFREELIST;
/* Bridge out structure for RGXCreateFreeList */
typedef struct PVRSRV_BRIDGE_OUT_RGXCREATEFREELIST_TAG
{
IMG_HANDLE hCleanupCookie;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCREATEFREELIST;
/*******************************************
RGXCreateRenderContext
*******************************************/
/* Bridge in structure for RGXCreateRenderContext */
typedef struct PVRSRV_BRIDGE_IN_RGXCREATERENDERCONTEXT_TAG
{
IMG_DEV_VIRTADDR sVDMCallStackAddr;
IMG_UINT64 ui64RobustnessAddress;
IMG_HANDLE hPrivData;
IMG_BYTE *pui8FragContextData;
IMG_BYTE *pui8FrameworkCmd;
IMG_BYTE *pui8GeomContextData;
IMG_INT32 i32Priority;
IMG_UINT32 ui32ContextFlags;
IMG_UINT32 ui32FragContextDataSize;
IMG_UINT32 ui32FrameworkCmdSize;
IMG_UINT32 ui32GeomContextDataSize;
IMG_UINT32 ui32Max3DDeadlineMS;
IMG_UINT32 ui32MaxTADeadlineMS;
IMG_UINT32 ui32PackedCCBSizeU8888;
IMG_UINT32 ui32ui32CallStackDepth;
} __packed PVRSRV_BRIDGE_IN_RGXCREATERENDERCONTEXT;
/* Bridge out structure for RGXCreateRenderContext */
typedef struct PVRSRV_BRIDGE_OUT_RGXCREATERENDERCONTEXT_TAG
{
IMG_HANDLE hRenderContext;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCREATERENDERCONTEXT;
#endif /* COMMON_RGXTA3D_BRIDGE_H */

View File

@@ -0,0 +1,112 @@
/*******************************************************************************
@File
@Title Common bridge header for rgxtimerquery
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for rgxtimerquery
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_RGXTIMERQUERY_BRIDGE_H
#define COMMON_RGXTIMERQUERY_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "rgx_bridge.h"
#define PVRSRV_BRIDGE_RGXTIMERQUERY_CMD_FIRST 0
#define PVRSRV_BRIDGE_RGXTIMERQUERY_RGXBEGINTIMERQUERY PVRSRV_BRIDGE_RGXTIMERQUERY_CMD_FIRST+0
#define PVRSRV_BRIDGE_RGXTIMERQUERY_RGXENDTIMERQUERY PVRSRV_BRIDGE_RGXTIMERQUERY_CMD_FIRST+1
#define PVRSRV_BRIDGE_RGXTIMERQUERY_RGXQUERYTIMER PVRSRV_BRIDGE_RGXTIMERQUERY_CMD_FIRST+2
#define PVRSRV_BRIDGE_RGXTIMERQUERY_CMD_LAST (PVRSRV_BRIDGE_RGXTIMERQUERY_CMD_FIRST+2)
/*******************************************
RGXBeginTimerQuery
*******************************************/
/* Bridge in structure for RGXBeginTimerQuery */
typedef struct PVRSRV_BRIDGE_IN_RGXBEGINTIMERQUERY_TAG
{
IMG_UINT32 ui32QueryId;
} __packed PVRSRV_BRIDGE_IN_RGXBEGINTIMERQUERY;
/* Bridge out structure for RGXBeginTimerQuery */
typedef struct PVRSRV_BRIDGE_OUT_RGXBEGINTIMERQUERY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXBEGINTIMERQUERY;
/*******************************************
RGXEndTimerQuery
*******************************************/
/* Bridge in structure for RGXEndTimerQuery */
typedef struct PVRSRV_BRIDGE_IN_RGXENDTIMERQUERY_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXENDTIMERQUERY;
/* Bridge out structure for RGXEndTimerQuery */
typedef struct PVRSRV_BRIDGE_OUT_RGXENDTIMERQUERY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXENDTIMERQUERY;
/*******************************************
RGXQueryTimer
*******************************************/
/* Bridge in structure for RGXQueryTimer */
typedef struct PVRSRV_BRIDGE_IN_RGXQUERYTIMER_TAG
{
IMG_UINT32 ui32QueryId;
} __packed PVRSRV_BRIDGE_IN_RGXQUERYTIMER;
/* Bridge out structure for RGXQueryTimer */
typedef struct PVRSRV_BRIDGE_OUT_RGXQUERYTIMER_TAG
{
IMG_UINT64 ui64EndTime;
IMG_UINT64 ui64StartTime;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXQUERYTIMER;
#endif /* COMMON_RGXTIMERQUERY_BRIDGE_H */

View File

@@ -0,0 +1,209 @@
/*******************************************************************************
@File
@Title Common bridge header for rgxtq2
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for rgxtq2
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_RGXTQ2_BRIDGE_H
#define COMMON_RGXTQ2_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "rgx_bridge.h"
#include "pvrsrv_sync_km.h"
#define PVRSRV_BRIDGE_RGXTQ2_CMD_FIRST 0
#define PVRSRV_BRIDGE_RGXTQ2_RGXTDMCREATETRANSFERCONTEXT PVRSRV_BRIDGE_RGXTQ2_CMD_FIRST+0
#define PVRSRV_BRIDGE_RGXTQ2_RGXTDMDESTROYTRANSFERCONTEXT PVRSRV_BRIDGE_RGXTQ2_CMD_FIRST+1
#define PVRSRV_BRIDGE_RGXTQ2_RGXTDMSETTRANSFERCONTEXTPRIORITY PVRSRV_BRIDGE_RGXTQ2_CMD_FIRST+2
#define PVRSRV_BRIDGE_RGXTQ2_RGXTDMNOTIFYWRITEOFFSETUPDATE PVRSRV_BRIDGE_RGXTQ2_CMD_FIRST+3
#define PVRSRV_BRIDGE_RGXTQ2_RGXTDMSUBMITTRANSFER2 PVRSRV_BRIDGE_RGXTQ2_CMD_FIRST+4
#define PVRSRV_BRIDGE_RGXTQ2_RGXTDMGETSHAREDMEMORY PVRSRV_BRIDGE_RGXTQ2_CMD_FIRST+5
#define PVRSRV_BRIDGE_RGXTQ2_RGXTDMRELEASESHAREDMEMORY PVRSRV_BRIDGE_RGXTQ2_CMD_FIRST+6
#define PVRSRV_BRIDGE_RGXTQ2_CMD_LAST (PVRSRV_BRIDGE_RGXTQ2_CMD_FIRST+6)
/*******************************************
RGXTDMCreateTransferContext
*******************************************/
/* Bridge in structure for RGXTDMCreateTransferContext */
typedef struct PVRSRV_BRIDGE_IN_RGXTDMCREATETRANSFERCONTEXT_TAG
{
IMG_UINT64 ui64RobustnessAddress;
IMG_HANDLE hPrivData;
IMG_BYTE *pui8FrameworkCmd;
IMG_INT32 i32Priority;
IMG_UINT32 ui32ContextFlags;
IMG_UINT32 ui32FrameworkCmdSize;
IMG_UINT32 ui32MaxDeadlineMS;
IMG_UINT32 ui32PackedCCBSizeU88;
} __packed PVRSRV_BRIDGE_IN_RGXTDMCREATETRANSFERCONTEXT;
/* Bridge out structure for RGXTDMCreateTransferContext */
typedef struct PVRSRV_BRIDGE_OUT_RGXTDMCREATETRANSFERCONTEXT_TAG
{
IMG_HANDLE hTransferContext;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXTDMCREATETRANSFERCONTEXT;
/*******************************************
RGXTDMDestroyTransferContext
*******************************************/
/* Bridge in structure for RGXTDMDestroyTransferContext */
typedef struct PVRSRV_BRIDGE_IN_RGXTDMDESTROYTRANSFERCONTEXT_TAG
{
IMG_HANDLE hTransferContext;
} __packed PVRSRV_BRIDGE_IN_RGXTDMDESTROYTRANSFERCONTEXT;
/* Bridge out structure for RGXTDMDestroyTransferContext */
typedef struct PVRSRV_BRIDGE_OUT_RGXTDMDESTROYTRANSFERCONTEXT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXTDMDESTROYTRANSFERCONTEXT;
/*******************************************
RGXTDMSetTransferContextPriority
*******************************************/
/* Bridge in structure for RGXTDMSetTransferContextPriority */
typedef struct PVRSRV_BRIDGE_IN_RGXTDMSETTRANSFERCONTEXTPRIORITY_TAG
{
IMG_HANDLE hTransferContext;
IMG_INT32 i32Priority;
} __packed PVRSRV_BRIDGE_IN_RGXTDMSETTRANSFERCONTEXTPRIORITY;
/* Bridge out structure for RGXTDMSetTransferContextPriority */
typedef struct PVRSRV_BRIDGE_OUT_RGXTDMSETTRANSFERCONTEXTPRIORITY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXTDMSETTRANSFERCONTEXTPRIORITY;
/*******************************************
RGXTDMNotifyWriteOffsetUpdate
*******************************************/
/* Bridge in structure for RGXTDMNotifyWriteOffsetUpdate */
typedef struct PVRSRV_BRIDGE_IN_RGXTDMNOTIFYWRITEOFFSETUPDATE_TAG
{
IMG_HANDLE hTransferContext;
IMG_UINT32 ui32PDumpFlags;
} __packed PVRSRV_BRIDGE_IN_RGXTDMNOTIFYWRITEOFFSETUPDATE;
/* Bridge out structure for RGXTDMNotifyWriteOffsetUpdate */
typedef struct PVRSRV_BRIDGE_OUT_RGXTDMNOTIFYWRITEOFFSETUPDATE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXTDMNOTIFYWRITEOFFSETUPDATE;
/*******************************************
RGXTDMSubmitTransfer2
*******************************************/
/* Bridge in structure for RGXTDMSubmitTransfer2 */
typedef struct PVRSRV_BRIDGE_IN_RGXTDMSUBMITTRANSFER2_TAG
{
IMG_UINT64 ui64DeadlineInus;
IMG_HANDLE hTransferContext;
IMG_UINT32 *pui32SyncPMRFlags;
IMG_UINT32 *pui32UpdateSyncOffset;
IMG_UINT32 *pui32UpdateValue;
IMG_UINT8 *pui8FWCommand;
IMG_CHAR *puiUpdateFenceName;
IMG_HANDLE *phSyncPMRs;
IMG_HANDLE *phUpdateUFOSyncPrimBlock;
PVRSRV_FENCE hCheckFenceFD;
PVRSRV_FENCE hExportFenceToSignal;
PVRSRV_TIMELINE hUpdateTimeline;
IMG_UINT32 ui32Characteristic1;
IMG_UINT32 ui32Characteristic2;
IMG_UINT32 ui32ClientUpdateCount;
IMG_UINT32 ui32CommandSize;
IMG_UINT32 ui32ExternalJobReference;
IMG_UINT32 ui32PDumpFlags;
IMG_UINT32 ui32SyncPMRCount;
} __packed PVRSRV_BRIDGE_IN_RGXTDMSUBMITTRANSFER2;
/* Bridge out structure for RGXTDMSubmitTransfer2 */
typedef struct PVRSRV_BRIDGE_OUT_RGXTDMSUBMITTRANSFER2_TAG
{
PVRSRV_ERROR eError;
PVRSRV_FENCE hUpdateFence;
} __packed PVRSRV_BRIDGE_OUT_RGXTDMSUBMITTRANSFER2;
/*******************************************
RGXTDMGetSharedMemory
*******************************************/
/* Bridge in structure for RGXTDMGetSharedMemory */
typedef struct PVRSRV_BRIDGE_IN_RGXTDMGETSHAREDMEMORY_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXTDMGETSHAREDMEMORY;
/* Bridge out structure for RGXTDMGetSharedMemory */
typedef struct PVRSRV_BRIDGE_OUT_RGXTDMGETSHAREDMEMORY_TAG
{
IMG_HANDLE hCLIPMRMem;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXTDMGETSHAREDMEMORY;
/*******************************************
RGXTDMReleaseSharedMemory
*******************************************/
/* Bridge in structure for RGXTDMReleaseSharedMemory */
typedef struct PVRSRV_BRIDGE_IN_RGXTDMRELEASESHAREDMEMORY_TAG
{
IMG_HANDLE hPMRMem;
} __packed PVRSRV_BRIDGE_IN_RGXTDMRELEASESHAREDMEMORY;
/* Bridge out structure for RGXTDMReleaseSharedMemory */
typedef struct PVRSRV_BRIDGE_OUT_RGXTDMRELEASESHAREDMEMORY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXTDMRELEASESHAREDMEMORY;
#endif /* COMMON_RGXTQ2_BRIDGE_H */

View File

@@ -0,0 +1,190 @@
/*******************************************************************************
@File
@Title Common bridge header for rgxtq
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for rgxtq
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_RGXTQ_BRIDGE_H
#define COMMON_RGXTQ_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "rgx_bridge.h"
#include "pvrsrv_sync_km.h"
#define PVRSRV_BRIDGE_RGXTQ_CMD_FIRST 0
#define PVRSRV_BRIDGE_RGXTQ_RGXCREATETRANSFERCONTEXT PVRSRV_BRIDGE_RGXTQ_CMD_FIRST+0
#define PVRSRV_BRIDGE_RGXTQ_RGXDESTROYTRANSFERCONTEXT PVRSRV_BRIDGE_RGXTQ_CMD_FIRST+1
#define PVRSRV_BRIDGE_RGXTQ_RGXSETTRANSFERCONTEXTPRIORITY PVRSRV_BRIDGE_RGXTQ_CMD_FIRST+2
#define PVRSRV_BRIDGE_RGXTQ_RGXSUBMITTRANSFER2 PVRSRV_BRIDGE_RGXTQ_CMD_FIRST+3
#define PVRSRV_BRIDGE_RGXTQ_RGXTQGETSHAREDMEMORY PVRSRV_BRIDGE_RGXTQ_CMD_FIRST+4
#define PVRSRV_BRIDGE_RGXTQ_RGXTQRELEASESHAREDMEMORY PVRSRV_BRIDGE_RGXTQ_CMD_FIRST+5
#define PVRSRV_BRIDGE_RGXTQ_CMD_LAST (PVRSRV_BRIDGE_RGXTQ_CMD_FIRST+5)
/*******************************************
RGXCreateTransferContext
*******************************************/
/* Bridge in structure for RGXCreateTransferContext */
typedef struct PVRSRV_BRIDGE_IN_RGXCREATETRANSFERCONTEXT_TAG
{
IMG_UINT64 ui64RobustnessAddress;
IMG_HANDLE hPrivData;
IMG_BYTE *pui8FrameworkCmd;
IMG_INT32 i32Priority;
IMG_UINT32 ui32ContextFlags;
IMG_UINT32 ui32FrameworkCmdize;
IMG_UINT32 ui32PackedCCBSizeU8888;
} __packed PVRSRV_BRIDGE_IN_RGXCREATETRANSFERCONTEXT;
/* Bridge out structure for RGXCreateTransferContext */
typedef struct PVRSRV_BRIDGE_OUT_RGXCREATETRANSFERCONTEXT_TAG
{
IMG_HANDLE hTransferContext;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXCREATETRANSFERCONTEXT;
/*******************************************
RGXDestroyTransferContext
*******************************************/
/* Bridge in structure for RGXDestroyTransferContext */
typedef struct PVRSRV_BRIDGE_IN_RGXDESTROYTRANSFERCONTEXT_TAG
{
IMG_HANDLE hTransferContext;
} __packed PVRSRV_BRIDGE_IN_RGXDESTROYTRANSFERCONTEXT;
/* Bridge out structure for RGXDestroyTransferContext */
typedef struct PVRSRV_BRIDGE_OUT_RGXDESTROYTRANSFERCONTEXT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXDESTROYTRANSFERCONTEXT;
/*******************************************
RGXSetTransferContextPriority
*******************************************/
/* Bridge in structure for RGXSetTransferContextPriority */
typedef struct PVRSRV_BRIDGE_IN_RGXSETTRANSFERCONTEXTPRIORITY_TAG
{
IMG_HANDLE hTransferContext;
IMG_INT32 i32Priority;
} __packed PVRSRV_BRIDGE_IN_RGXSETTRANSFERCONTEXTPRIORITY;
/* Bridge out structure for RGXSetTransferContextPriority */
typedef struct PVRSRV_BRIDGE_OUT_RGXSETTRANSFERCONTEXTPRIORITY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXSETTRANSFERCONTEXTPRIORITY;
/*******************************************
RGXSubmitTransfer2
*******************************************/
/* Bridge in structure for RGXSubmitTransfer2 */
typedef struct PVRSRV_BRIDGE_IN_RGXSUBMITTRANSFER2_TAG
{
IMG_HANDLE hTransferContext;
IMG_UINT32 *pui32ClientUpdateCount;
IMG_UINT32 *pui32CommandSize;
IMG_UINT32 *pui32SyncPMRFlags;
IMG_UINT32 *pui32TQPrepareFlags;
IMG_UINT32 **pui32UpdateSyncOffset;
IMG_UINT32 **pui32UpdateValue;
IMG_UINT8 **pui8FWCommand;
IMG_CHAR *puiUpdateFenceName;
IMG_HANDLE *phSyncPMRs;
IMG_HANDLE **phUpdateUFOSyncPrimBlock;
PVRSRV_TIMELINE h2DUpdateTimeline;
PVRSRV_TIMELINE h3DUpdateTimeline;
PVRSRV_FENCE hCheckFenceFD;
PVRSRV_FENCE hExportFenceToSignal;
IMG_UINT32 ui32ExtJobRef;
IMG_UINT32 ui32PrepareCount;
IMG_UINT32 ui32SyncPMRCount;
} __packed PVRSRV_BRIDGE_IN_RGXSUBMITTRANSFER2;
/* Bridge out structure for RGXSubmitTransfer2 */
typedef struct PVRSRV_BRIDGE_OUT_RGXSUBMITTRANSFER2_TAG
{
PVRSRV_ERROR eError;
PVRSRV_FENCE h2DUpdateFence;
PVRSRV_FENCE h3DUpdateFence;
} __packed PVRSRV_BRIDGE_OUT_RGXSUBMITTRANSFER2;
/*******************************************
RGXTQGetSharedMemory
*******************************************/
/* Bridge in structure for RGXTQGetSharedMemory */
typedef struct PVRSRV_BRIDGE_IN_RGXTQGETSHAREDMEMORY_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RGXTQGETSHAREDMEMORY;
/* Bridge out structure for RGXTQGetSharedMemory */
typedef struct PVRSRV_BRIDGE_OUT_RGXTQGETSHAREDMEMORY_TAG
{
IMG_HANDLE hCLIPMRMem;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXTQGETSHAREDMEMORY;
/*******************************************
RGXTQReleaseSharedMemory
*******************************************/
/* Bridge in structure for RGXTQReleaseSharedMemory */
typedef struct PVRSRV_BRIDGE_IN_RGXTQRELEASESHAREDMEMORY_TAG
{
IMG_HANDLE hPMRMem;
} __packed PVRSRV_BRIDGE_IN_RGXTQRELEASESHAREDMEMORY;
/* Bridge out structure for RGXTQReleaseSharedMemory */
typedef struct PVRSRV_BRIDGE_OUT_RGXTQRELEASESHAREDMEMORY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RGXTQRELEASESHAREDMEMORY;
#endif /* COMMON_RGXTQ_BRIDGE_H */

View File

@@ -0,0 +1,224 @@
/*******************************************************************************
@File
@Title Common bridge header for ri
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for ri
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_RI_BRIDGE_H
#define COMMON_RI_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "ri_typedefs.h"
#define PVRSRV_BRIDGE_RI_CMD_FIRST 0
#define PVRSRV_BRIDGE_RI_RIWRITEPMRENTRY PVRSRV_BRIDGE_RI_CMD_FIRST+0
#define PVRSRV_BRIDGE_RI_RIWRITEMEMDESCENTRY PVRSRV_BRIDGE_RI_CMD_FIRST+1
#define PVRSRV_BRIDGE_RI_RIWRITEPROCLISTENTRY PVRSRV_BRIDGE_RI_CMD_FIRST+2
#define PVRSRV_BRIDGE_RI_RIUPDATEMEMDESCADDR PVRSRV_BRIDGE_RI_CMD_FIRST+3
#define PVRSRV_BRIDGE_RI_RIDELETEMEMDESCENTRY PVRSRV_BRIDGE_RI_CMD_FIRST+4
#define PVRSRV_BRIDGE_RI_RIDUMPLIST PVRSRV_BRIDGE_RI_CMD_FIRST+5
#define PVRSRV_BRIDGE_RI_RIDUMPALL PVRSRV_BRIDGE_RI_CMD_FIRST+6
#define PVRSRV_BRIDGE_RI_RIDUMPPROCESS PVRSRV_BRIDGE_RI_CMD_FIRST+7
#define PVRSRV_BRIDGE_RI_RIWRITEPMRENTRYWITHOWNER PVRSRV_BRIDGE_RI_CMD_FIRST+8
#define PVRSRV_BRIDGE_RI_CMD_LAST (PVRSRV_BRIDGE_RI_CMD_FIRST+8)
/*******************************************
RIWritePMREntry
*******************************************/
/* Bridge in structure for RIWritePMREntry */
typedef struct PVRSRV_BRIDGE_IN_RIWRITEPMRENTRY_TAG
{
IMG_HANDLE hPMRHandle;
} __packed PVRSRV_BRIDGE_IN_RIWRITEPMRENTRY;
/* Bridge out structure for RIWritePMREntry */
typedef struct PVRSRV_BRIDGE_OUT_RIWRITEPMRENTRY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RIWRITEPMRENTRY;
/*******************************************
RIWriteMEMDESCEntry
*******************************************/
/* Bridge in structure for RIWriteMEMDESCEntry */
typedef struct PVRSRV_BRIDGE_IN_RIWRITEMEMDESCENTRY_TAG
{
IMG_UINT64 ui64Flags;
IMG_UINT64 ui64Offset;
IMG_UINT64 ui64Size;
IMG_HANDLE hPMRHandle;
const IMG_CHAR *puiTextB;
IMG_UINT32 ui32TextBSize;
} __packed PVRSRV_BRIDGE_IN_RIWRITEMEMDESCENTRY;
/* Bridge out structure for RIWriteMEMDESCEntry */
typedef struct PVRSRV_BRIDGE_OUT_RIWRITEMEMDESCENTRY_TAG
{
IMG_HANDLE hRIHandle;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RIWRITEMEMDESCENTRY;
/*******************************************
RIWriteProcListEntry
*******************************************/
/* Bridge in structure for RIWriteProcListEntry */
typedef struct PVRSRV_BRIDGE_IN_RIWRITEPROCLISTENTRY_TAG
{
IMG_UINT64 ui64DevVAddr;
IMG_UINT64 ui64Size;
const IMG_CHAR *puiTextB;
IMG_UINT32 ui32TextBSize;
} __packed PVRSRV_BRIDGE_IN_RIWRITEPROCLISTENTRY;
/* Bridge out structure for RIWriteProcListEntry */
typedef struct PVRSRV_BRIDGE_OUT_RIWRITEPROCLISTENTRY_TAG
{
IMG_HANDLE hRIHandle;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RIWRITEPROCLISTENTRY;
/*******************************************
RIUpdateMEMDESCAddr
*******************************************/
/* Bridge in structure for RIUpdateMEMDESCAddr */
typedef struct PVRSRV_BRIDGE_IN_RIUPDATEMEMDESCADDR_TAG
{
IMG_DEV_VIRTADDR sAddr;
IMG_HANDLE hRIHandle;
} __packed PVRSRV_BRIDGE_IN_RIUPDATEMEMDESCADDR;
/* Bridge out structure for RIUpdateMEMDESCAddr */
typedef struct PVRSRV_BRIDGE_OUT_RIUPDATEMEMDESCADDR_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RIUPDATEMEMDESCADDR;
/*******************************************
RIDeleteMEMDESCEntry
*******************************************/
/* Bridge in structure for RIDeleteMEMDESCEntry */
typedef struct PVRSRV_BRIDGE_IN_RIDELETEMEMDESCENTRY_TAG
{
IMG_HANDLE hRIHandle;
} __packed PVRSRV_BRIDGE_IN_RIDELETEMEMDESCENTRY;
/* Bridge out structure for RIDeleteMEMDESCEntry */
typedef struct PVRSRV_BRIDGE_OUT_RIDELETEMEMDESCENTRY_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RIDELETEMEMDESCENTRY;
/*******************************************
RIDumpList
*******************************************/
/* Bridge in structure for RIDumpList */
typedef struct PVRSRV_BRIDGE_IN_RIDUMPLIST_TAG
{
IMG_HANDLE hPMRHandle;
} __packed PVRSRV_BRIDGE_IN_RIDUMPLIST;
/* Bridge out structure for RIDumpList */
typedef struct PVRSRV_BRIDGE_OUT_RIDUMPLIST_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RIDUMPLIST;
/*******************************************
RIDumpAll
*******************************************/
/* Bridge in structure for RIDumpAll */
typedef struct PVRSRV_BRIDGE_IN_RIDUMPALL_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_RIDUMPALL;
/* Bridge out structure for RIDumpAll */
typedef struct PVRSRV_BRIDGE_OUT_RIDUMPALL_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RIDUMPALL;
/*******************************************
RIDumpProcess
*******************************************/
/* Bridge in structure for RIDumpProcess */
typedef struct PVRSRV_BRIDGE_IN_RIDUMPPROCESS_TAG
{
IMG_PID ui32Pid;
} __packed PVRSRV_BRIDGE_IN_RIDUMPPROCESS;
/* Bridge out structure for RIDumpProcess */
typedef struct PVRSRV_BRIDGE_OUT_RIDUMPPROCESS_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RIDUMPPROCESS;
/*******************************************
RIWritePMREntryWithOwner
*******************************************/
/* Bridge in structure for RIWritePMREntryWithOwner */
typedef struct PVRSRV_BRIDGE_IN_RIWRITEPMRENTRYWITHOWNER_TAG
{
IMG_HANDLE hPMRHandle;
IMG_PID ui32Owner;
} __packed PVRSRV_BRIDGE_IN_RIWRITEPMRENTRYWITHOWNER;
/* Bridge out structure for RIWritePMREntryWithOwner */
typedef struct PVRSRV_BRIDGE_OUT_RIWRITEPMRENTRYWITHOWNER_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RIWRITEPMRENTRYWITHOWNER;
#endif /* COMMON_RI_BRIDGE_H */

View File

@@ -0,0 +1,405 @@
/*******************************************************************************
@File
@Title Common bridge header for srvcore
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for srvcore
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_SRVCORE_BRIDGE_H
#define COMMON_SRVCORE_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "pvrsrv_device_types.h"
#include "cache_ops.h"
#define PVRSRV_BRIDGE_SRVCORE_CMD_FIRST 0
#define PVRSRV_BRIDGE_SRVCORE_CONNECT PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+0
#define PVRSRV_BRIDGE_SRVCORE_DISCONNECT PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+1
#define PVRSRV_BRIDGE_SRVCORE_ACQUIREGLOBALEVENTOBJECT PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+2
#define PVRSRV_BRIDGE_SRVCORE_RELEASEGLOBALEVENTOBJECT PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+3
#define PVRSRV_BRIDGE_SRVCORE_EVENTOBJECTOPEN PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+4
#define PVRSRV_BRIDGE_SRVCORE_EVENTOBJECTWAIT PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+5
#define PVRSRV_BRIDGE_SRVCORE_EVENTOBJECTCLOSE PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+6
#define PVRSRV_BRIDGE_SRVCORE_DUMPDEBUGINFO PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+7
#define PVRSRV_BRIDGE_SRVCORE_GETDEVCLOCKSPEED PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+8
#define PVRSRV_BRIDGE_SRVCORE_HWOPTIMEOUT PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+9
#define PVRSRV_BRIDGE_SRVCORE_ALIGNMENTCHECK PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+10
#define PVRSRV_BRIDGE_SRVCORE_GETDEVICESTATUS PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+11
#define PVRSRV_BRIDGE_SRVCORE_GETMULTICOREINFO PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+12
#define PVRSRV_BRIDGE_SRVCORE_EVENTOBJECTWAITTIMEOUT PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+13
#define PVRSRV_BRIDGE_SRVCORE_FINDPROCESSMEMSTATS PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+14
#define PVRSRV_BRIDGE_SRVCORE_ACQUIREINFOPAGE PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+15
#define PVRSRV_BRIDGE_SRVCORE_RELEASEINFOPAGE PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+16
#define PVRSRV_BRIDGE_SRVCORE_GETSLCSIZE PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+17
#define PVRSRV_BRIDGE_SRVCORE_GETSOCFREQ PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+18
#define PVRSRV_BRIDGE_SRVCORE_CMD_LAST (PVRSRV_BRIDGE_SRVCORE_CMD_FIRST+18)
/*******************************************
Connect
*******************************************/
/* Bridge in structure for Connect */
typedef struct PVRSRV_BRIDGE_IN_CONNECT_TAG
{
IMG_UINT32 ui32ClientBuildOptions;
IMG_UINT32 ui32ClientDDKBuild;
IMG_UINT32 ui32ClientDDKVersion;
IMG_UINT32 ui32Flags;
} __packed PVRSRV_BRIDGE_IN_CONNECT;
/* Bridge out structure for Connect */
typedef struct PVRSRV_BRIDGE_OUT_CONNECT_TAG
{
IMG_UINT64 ui64PackedBvnc;
PVRSRV_ERROR eError;
IMG_UINT32 ui32CapabilityFlags;
IMG_UINT8 ui8KernelArch;
} __packed PVRSRV_BRIDGE_OUT_CONNECT;
/*******************************************
Disconnect
*******************************************/
/* Bridge in structure for Disconnect */
typedef struct PVRSRV_BRIDGE_IN_DISCONNECT_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_DISCONNECT;
/* Bridge out structure for Disconnect */
typedef struct PVRSRV_BRIDGE_OUT_DISCONNECT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DISCONNECT;
/*******************************************
AcquireGlobalEventObject
*******************************************/
/* Bridge in structure for AcquireGlobalEventObject */
typedef struct PVRSRV_BRIDGE_IN_ACQUIREGLOBALEVENTOBJECT_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_ACQUIREGLOBALEVENTOBJECT;
/* Bridge out structure for AcquireGlobalEventObject */
typedef struct PVRSRV_BRIDGE_OUT_ACQUIREGLOBALEVENTOBJECT_TAG
{
IMG_HANDLE hGlobalEventObject;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_ACQUIREGLOBALEVENTOBJECT;
/*******************************************
ReleaseGlobalEventObject
*******************************************/
/* Bridge in structure for ReleaseGlobalEventObject */
typedef struct PVRSRV_BRIDGE_IN_RELEASEGLOBALEVENTOBJECT_TAG
{
IMG_HANDLE hGlobalEventObject;
} __packed PVRSRV_BRIDGE_IN_RELEASEGLOBALEVENTOBJECT;
/* Bridge out structure for ReleaseGlobalEventObject */
typedef struct PVRSRV_BRIDGE_OUT_RELEASEGLOBALEVENTOBJECT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RELEASEGLOBALEVENTOBJECT;
/*******************************************
EventObjectOpen
*******************************************/
/* Bridge in structure for EventObjectOpen */
typedef struct PVRSRV_BRIDGE_IN_EVENTOBJECTOPEN_TAG
{
IMG_HANDLE hEventObject;
} __packed PVRSRV_BRIDGE_IN_EVENTOBJECTOPEN;
/* Bridge out structure for EventObjectOpen */
typedef struct PVRSRV_BRIDGE_OUT_EVENTOBJECTOPEN_TAG
{
IMG_HANDLE hOSEvent;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_EVENTOBJECTOPEN;
/*******************************************
EventObjectWait
*******************************************/
/* Bridge in structure for EventObjectWait */
typedef struct PVRSRV_BRIDGE_IN_EVENTOBJECTWAIT_TAG
{
IMG_HANDLE hOSEventKM;
} __packed PVRSRV_BRIDGE_IN_EVENTOBJECTWAIT;
/* Bridge out structure for EventObjectWait */
typedef struct PVRSRV_BRIDGE_OUT_EVENTOBJECTWAIT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_EVENTOBJECTWAIT;
/*******************************************
EventObjectClose
*******************************************/
/* Bridge in structure for EventObjectClose */
typedef struct PVRSRV_BRIDGE_IN_EVENTOBJECTCLOSE_TAG
{
IMG_HANDLE hOSEventKM;
} __packed PVRSRV_BRIDGE_IN_EVENTOBJECTCLOSE;
/* Bridge out structure for EventObjectClose */
typedef struct PVRSRV_BRIDGE_OUT_EVENTOBJECTCLOSE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_EVENTOBJECTCLOSE;
/*******************************************
DumpDebugInfo
*******************************************/
/* Bridge in structure for DumpDebugInfo */
typedef struct PVRSRV_BRIDGE_IN_DUMPDEBUGINFO_TAG
{
IMG_UINT32 ui32VerbLevel;
} __packed PVRSRV_BRIDGE_IN_DUMPDEBUGINFO;
/* Bridge out structure for DumpDebugInfo */
typedef struct PVRSRV_BRIDGE_OUT_DUMPDEBUGINFO_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_DUMPDEBUGINFO;
/*******************************************
GetDevClockSpeed
*******************************************/
/* Bridge in structure for GetDevClockSpeed */
typedef struct PVRSRV_BRIDGE_IN_GETDEVCLOCKSPEED_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_GETDEVCLOCKSPEED;
/* Bridge out structure for GetDevClockSpeed */
typedef struct PVRSRV_BRIDGE_OUT_GETDEVCLOCKSPEED_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32ClockSpeed;
} __packed PVRSRV_BRIDGE_OUT_GETDEVCLOCKSPEED;
/*******************************************
HWOpTimeout
*******************************************/
/* Bridge in structure for HWOpTimeout */
typedef struct PVRSRV_BRIDGE_IN_HWOPTIMEOUT_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_HWOPTIMEOUT;
/* Bridge out structure for HWOpTimeout */
typedef struct PVRSRV_BRIDGE_OUT_HWOPTIMEOUT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_HWOPTIMEOUT;
/*******************************************
AlignmentCheck
*******************************************/
/* Bridge in structure for AlignmentCheck */
typedef struct PVRSRV_BRIDGE_IN_ALIGNMENTCHECK_TAG
{
IMG_UINT32 *pui32AlignChecks;
IMG_UINT32 ui32AlignChecksSize;
} __packed PVRSRV_BRIDGE_IN_ALIGNMENTCHECK;
/* Bridge out structure for AlignmentCheck */
typedef struct PVRSRV_BRIDGE_OUT_ALIGNMENTCHECK_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_ALIGNMENTCHECK;
/*******************************************
GetDeviceStatus
*******************************************/
/* Bridge in structure for GetDeviceStatus */
typedef struct PVRSRV_BRIDGE_IN_GETDEVICESTATUS_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_GETDEVICESTATUS;
/* Bridge out structure for GetDeviceStatus */
typedef struct PVRSRV_BRIDGE_OUT_GETDEVICESTATUS_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32DeviceSatus;
} __packed PVRSRV_BRIDGE_OUT_GETDEVICESTATUS;
/*******************************************
GetMultiCoreInfo
*******************************************/
/* Bridge in structure for GetMultiCoreInfo */
typedef struct PVRSRV_BRIDGE_IN_GETMULTICOREINFO_TAG
{
IMG_UINT64 *pui64Caps;
IMG_UINT32 ui32CapsSize;
} __packed PVRSRV_BRIDGE_IN_GETMULTICOREINFO;
/* Bridge out structure for GetMultiCoreInfo */
typedef struct PVRSRV_BRIDGE_OUT_GETMULTICOREINFO_TAG
{
IMG_UINT64 *pui64Caps;
PVRSRV_ERROR eError;
IMG_UINT32 ui32NumCores;
} __packed PVRSRV_BRIDGE_OUT_GETMULTICOREINFO;
/*******************************************
EventObjectWaitTimeout
*******************************************/
/* Bridge in structure for EventObjectWaitTimeout */
typedef struct PVRSRV_BRIDGE_IN_EVENTOBJECTWAITTIMEOUT_TAG
{
IMG_UINT64 ui64uiTimeoutus;
IMG_HANDLE hOSEventKM;
} __packed PVRSRV_BRIDGE_IN_EVENTOBJECTWAITTIMEOUT;
/* Bridge out structure for EventObjectWaitTimeout */
typedef struct PVRSRV_BRIDGE_OUT_EVENTOBJECTWAITTIMEOUT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_EVENTOBJECTWAITTIMEOUT;
/*******************************************
FindProcessMemStats
*******************************************/
/* Bridge in structure for FindProcessMemStats */
typedef struct PVRSRV_BRIDGE_IN_FINDPROCESSMEMSTATS_TAG
{
IMG_UINT64 *pui64MemStatsArray;
IMG_UINT32 ui32ArrSize;
IMG_UINT32 ui32PID;
IMG_BOOL bbAllProcessStats;
} __packed PVRSRV_BRIDGE_IN_FINDPROCESSMEMSTATS;
/* Bridge out structure for FindProcessMemStats */
typedef struct PVRSRV_BRIDGE_OUT_FINDPROCESSMEMSTATS_TAG
{
IMG_UINT64 *pui64MemStatsArray;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_FINDPROCESSMEMSTATS;
/*******************************************
AcquireInfoPage
*******************************************/
/* Bridge in structure for AcquireInfoPage */
typedef struct PVRSRV_BRIDGE_IN_ACQUIREINFOPAGE_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_ACQUIREINFOPAGE;
/* Bridge out structure for AcquireInfoPage */
typedef struct PVRSRV_BRIDGE_OUT_ACQUIREINFOPAGE_TAG
{
IMG_HANDLE hPMR;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_ACQUIREINFOPAGE;
/*******************************************
ReleaseInfoPage
*******************************************/
/* Bridge in structure for ReleaseInfoPage */
typedef struct PVRSRV_BRIDGE_IN_RELEASEINFOPAGE_TAG
{
IMG_HANDLE hPMR;
} __packed PVRSRV_BRIDGE_IN_RELEASEINFOPAGE;
/* Bridge out structure for ReleaseInfoPage */
typedef struct PVRSRV_BRIDGE_OUT_RELEASEINFOPAGE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_RELEASEINFOPAGE;
/*******************************************
GetSLCSize
*******************************************/
/* Bridge in structure for GetSLCSize */
typedef struct PVRSRV_BRIDGE_IN_GETSLCSIZE_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_GETSLCSIZE;
/* Bridge out structure for GetSLCSize */
typedef struct PVRSRV_BRIDGE_OUT_GETSLCSIZE_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32SLCSizeInBytes;
} __packed PVRSRV_BRIDGE_OUT_GETSLCSIZE;
/*******************************************
GetSocFreq
*******************************************/
/* Bridge in structure for GetSocFreq */
typedef struct PVRSRV_BRIDGE_IN_GETSOCFREQ_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_GETSOCFREQ;
/* Bridge out structure for GetSocFreq */
typedef struct PVRSRV_BRIDGE_OUT_GETSOCFREQ_TAG
{
PVRSRV_ERROR eError;
IMG_UINT32 ui32SocFreq;
} __packed PVRSRV_BRIDGE_OUT_GETSOCFREQ;
#endif /* COMMON_SRVCORE_BRIDGE_H */

View File

@@ -0,0 +1,254 @@
/*******************************************************************************
@File
@Title Common bridge header for sync
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for sync
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_SYNC_BRIDGE_H
#define COMMON_SYNC_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "pdump.h"
#include "pdumpdefs.h"
#include "devicemem_typedefs.h"
#include "pvrsrv_sync_km.h"
#include <powervr/pvrsrv_sync_ext.h>
#define PVRSRV_BRIDGE_SYNC_CMD_FIRST 0
#define PVRSRV_BRIDGE_SYNC_ALLOCSYNCPRIMITIVEBLOCK PVRSRV_BRIDGE_SYNC_CMD_FIRST+0
#define PVRSRV_BRIDGE_SYNC_FREESYNCPRIMITIVEBLOCK PVRSRV_BRIDGE_SYNC_CMD_FIRST+1
#define PVRSRV_BRIDGE_SYNC_SYNCPRIMSET PVRSRV_BRIDGE_SYNC_CMD_FIRST+2
#define PVRSRV_BRIDGE_SYNC_SYNCPRIMPDUMP PVRSRV_BRIDGE_SYNC_CMD_FIRST+3
#define PVRSRV_BRIDGE_SYNC_SYNCPRIMPDUMPVALUE PVRSRV_BRIDGE_SYNC_CMD_FIRST+4
#define PVRSRV_BRIDGE_SYNC_SYNCPRIMPDUMPPOL PVRSRV_BRIDGE_SYNC_CMD_FIRST+5
#define PVRSRV_BRIDGE_SYNC_SYNCPRIMPDUMPCBP PVRSRV_BRIDGE_SYNC_CMD_FIRST+6
#define PVRSRV_BRIDGE_SYNC_SYNCALLOCEVENT PVRSRV_BRIDGE_SYNC_CMD_FIRST+7
#define PVRSRV_BRIDGE_SYNC_SYNCFREEEVENT PVRSRV_BRIDGE_SYNC_CMD_FIRST+8
#define PVRSRV_BRIDGE_SYNC_SYNCCHECKPOINTSIGNALLEDPDUMPPOL PVRSRV_BRIDGE_SYNC_CMD_FIRST+9
#define PVRSRV_BRIDGE_SYNC_CMD_LAST (PVRSRV_BRIDGE_SYNC_CMD_FIRST+9)
/*******************************************
AllocSyncPrimitiveBlock
*******************************************/
/* Bridge in structure for AllocSyncPrimitiveBlock */
typedef struct PVRSRV_BRIDGE_IN_ALLOCSYNCPRIMITIVEBLOCK_TAG
{
IMG_UINT32 ui32EmptyStructPlaceholder;
} __packed PVRSRV_BRIDGE_IN_ALLOCSYNCPRIMITIVEBLOCK;
/* Bridge out structure for AllocSyncPrimitiveBlock */
typedef struct PVRSRV_BRIDGE_OUT_ALLOCSYNCPRIMITIVEBLOCK_TAG
{
IMG_HANDLE hSyncHandle;
IMG_HANDLE hhSyncPMR;
PVRSRV_ERROR eError;
IMG_UINT32 ui32SyncPrimBlockSize;
IMG_UINT32 ui32SyncPrimVAddr;
} __packed PVRSRV_BRIDGE_OUT_ALLOCSYNCPRIMITIVEBLOCK;
/*******************************************
FreeSyncPrimitiveBlock
*******************************************/
/* Bridge in structure for FreeSyncPrimitiveBlock */
typedef struct PVRSRV_BRIDGE_IN_FREESYNCPRIMITIVEBLOCK_TAG
{
IMG_HANDLE hSyncHandle;
} __packed PVRSRV_BRIDGE_IN_FREESYNCPRIMITIVEBLOCK;
/* Bridge out structure for FreeSyncPrimitiveBlock */
typedef struct PVRSRV_BRIDGE_OUT_FREESYNCPRIMITIVEBLOCK_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_FREESYNCPRIMITIVEBLOCK;
/*******************************************
SyncPrimSet
*******************************************/
/* Bridge in structure for SyncPrimSet */
typedef struct PVRSRV_BRIDGE_IN_SYNCPRIMSET_TAG
{
IMG_HANDLE hSyncHandle;
IMG_UINT32 ui32Index;
IMG_UINT32 ui32Value;
} __packed PVRSRV_BRIDGE_IN_SYNCPRIMSET;
/* Bridge out structure for SyncPrimSet */
typedef struct PVRSRV_BRIDGE_OUT_SYNCPRIMSET_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_SYNCPRIMSET;
/*******************************************
SyncPrimPDump
*******************************************/
/* Bridge in structure for SyncPrimPDump */
typedef struct PVRSRV_BRIDGE_IN_SYNCPRIMPDUMP_TAG
{
IMG_HANDLE hSyncHandle;
IMG_UINT32 ui32Offset;
} __packed PVRSRV_BRIDGE_IN_SYNCPRIMPDUMP;
/* Bridge out structure for SyncPrimPDump */
typedef struct PVRSRV_BRIDGE_OUT_SYNCPRIMPDUMP_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_SYNCPRIMPDUMP;
/*******************************************
SyncPrimPDumpValue
*******************************************/
/* Bridge in structure for SyncPrimPDumpValue */
typedef struct PVRSRV_BRIDGE_IN_SYNCPRIMPDUMPVALUE_TAG
{
IMG_HANDLE hSyncHandle;
IMG_UINT32 ui32Offset;
IMG_UINT32 ui32Value;
} __packed PVRSRV_BRIDGE_IN_SYNCPRIMPDUMPVALUE;
/* Bridge out structure for SyncPrimPDumpValue */
typedef struct PVRSRV_BRIDGE_OUT_SYNCPRIMPDUMPVALUE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_SYNCPRIMPDUMPVALUE;
/*******************************************
SyncPrimPDumpPol
*******************************************/
/* Bridge in structure for SyncPrimPDumpPol */
typedef struct PVRSRV_BRIDGE_IN_SYNCPRIMPDUMPPOL_TAG
{
IMG_HANDLE hSyncHandle;
PDUMP_POLL_OPERATOR eOperator;
IMG_UINT32 ui32Mask;
IMG_UINT32 ui32Offset;
IMG_UINT32 ui32Value;
PDUMP_FLAGS_T uiPDumpFlags;
} __packed PVRSRV_BRIDGE_IN_SYNCPRIMPDUMPPOL;
/* Bridge out structure for SyncPrimPDumpPol */
typedef struct PVRSRV_BRIDGE_OUT_SYNCPRIMPDUMPPOL_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_SYNCPRIMPDUMPPOL;
/*******************************************
SyncPrimPDumpCBP
*******************************************/
/* Bridge in structure for SyncPrimPDumpCBP */
typedef struct PVRSRV_BRIDGE_IN_SYNCPRIMPDUMPCBP_TAG
{
IMG_DEVMEM_SIZE_T uiBufferSize;
IMG_DEVMEM_SIZE_T uiPacketSize;
IMG_DEVMEM_OFFSET_T uiWriteOffset;
IMG_HANDLE hSyncHandle;
IMG_UINT32 ui32Offset;
} __packed PVRSRV_BRIDGE_IN_SYNCPRIMPDUMPCBP;
/* Bridge out structure for SyncPrimPDumpCBP */
typedef struct PVRSRV_BRIDGE_OUT_SYNCPRIMPDUMPCBP_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_SYNCPRIMPDUMPCBP;
/*******************************************
SyncAllocEvent
*******************************************/
/* Bridge in structure for SyncAllocEvent */
typedef struct PVRSRV_BRIDGE_IN_SYNCALLOCEVENT_TAG
{
const IMG_CHAR *puiClassName;
IMG_UINT32 ui32ClassNameSize;
IMG_UINT32 ui32FWAddr;
IMG_BOOL bServerSync;
} __packed PVRSRV_BRIDGE_IN_SYNCALLOCEVENT;
/* Bridge out structure for SyncAllocEvent */
typedef struct PVRSRV_BRIDGE_OUT_SYNCALLOCEVENT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_SYNCALLOCEVENT;
/*******************************************
SyncFreeEvent
*******************************************/
/* Bridge in structure for SyncFreeEvent */
typedef struct PVRSRV_BRIDGE_IN_SYNCFREEEVENT_TAG
{
IMG_UINT32 ui32FWAddr;
} __packed PVRSRV_BRIDGE_IN_SYNCFREEEVENT;
/* Bridge out structure for SyncFreeEvent */
typedef struct PVRSRV_BRIDGE_OUT_SYNCFREEEVENT_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_SYNCFREEEVENT;
/*******************************************
SyncCheckpointSignalledPDumpPol
*******************************************/
/* Bridge in structure for SyncCheckpointSignalledPDumpPol */
typedef struct PVRSRV_BRIDGE_IN_SYNCCHECKPOINTSIGNALLEDPDUMPPOL_TAG
{
PVRSRV_FENCE hFence;
} __packed PVRSRV_BRIDGE_IN_SYNCCHECKPOINTSIGNALLEDPDUMPPOL;
/* Bridge out structure for SyncCheckpointSignalledPDumpPol */
typedef struct PVRSRV_BRIDGE_OUT_SYNCCHECKPOINTSIGNALLEDPDUMPPOL_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_SYNCCHECKPOINTSIGNALLEDPDUMPPOL;
#endif /* COMMON_SYNC_BRIDGE_H */

View File

@@ -0,0 +1,97 @@
/*******************************************************************************
@File
@Title Common bridge header for synctracking
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Declares common defines and structures used by both the client
and server side of the bridge for synctracking
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*******************************************************************************/
#ifndef COMMON_SYNCTRACKING_BRIDGE_H
#define COMMON_SYNCTRACKING_BRIDGE_H
#include <powervr/mem_types.h>
#include "img_defs.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#define PVRSRV_BRIDGE_SYNCTRACKING_CMD_FIRST 0
#define PVRSRV_BRIDGE_SYNCTRACKING_SYNCRECORDREMOVEBYHANDLE PVRSRV_BRIDGE_SYNCTRACKING_CMD_FIRST+0
#define PVRSRV_BRIDGE_SYNCTRACKING_SYNCRECORDADD PVRSRV_BRIDGE_SYNCTRACKING_CMD_FIRST+1
#define PVRSRV_BRIDGE_SYNCTRACKING_CMD_LAST (PVRSRV_BRIDGE_SYNCTRACKING_CMD_FIRST+1)
/*******************************************
SyncRecordRemoveByHandle
*******************************************/
/* Bridge in structure for SyncRecordRemoveByHandle */
typedef struct PVRSRV_BRIDGE_IN_SYNCRECORDREMOVEBYHANDLE_TAG
{
IMG_HANDLE hhRecord;
} __packed PVRSRV_BRIDGE_IN_SYNCRECORDREMOVEBYHANDLE;
/* Bridge out structure for SyncRecordRemoveByHandle */
typedef struct PVRSRV_BRIDGE_OUT_SYNCRECORDREMOVEBYHANDLE_TAG
{
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_SYNCRECORDREMOVEBYHANDLE;
/*******************************************
SyncRecordAdd
*******************************************/
/* Bridge in structure for SyncRecordAdd */
typedef struct PVRSRV_BRIDGE_IN_SYNCRECORDADD_TAG
{
IMG_HANDLE hhServerSyncPrimBlock;
const IMG_CHAR *puiClassName;
IMG_UINT32 ui32ClassNameSize;
IMG_UINT32 ui32ui32FwBlockAddr;
IMG_UINT32 ui32ui32SyncOffset;
IMG_BOOL bbServerSync;
} __packed PVRSRV_BRIDGE_IN_SYNCRECORDADD;
/* Bridge out structure for SyncRecordAdd */
typedef struct PVRSRV_BRIDGE_OUT_SYNCRECORDADD_TAG
{
IMG_HANDLE hhRecord;
PVRSRV_ERROR eError;
} __packed PVRSRV_BRIDGE_OUT_SYNCRECORDADD;
#endif /* COMMON_SYNCTRACKING_BRIDGE_H */

View File

@@ -0,0 +1,307 @@
#define PVRSRV_APPHINT_FIRMWARE_HEAP_POLICY 5
#define RGX_FW_FILENAME "rgx.fw"
#define RGX_SH_FILENAME "rgx.sh"
#define PVR_BUILD_DIR "xuantie_linux"
#define PVR_BUILD_TYPE "release"
#define PVRSRV_MODNAME "pvrsrvkm"
#define PVRSYNC_MODNAME "pvr_sync"
#define SUPPORT_RGX 1
#define DISPLAY_CONTROLLER drm_nulldisp
#define PVRSRV_MAX_DEVICES 8
#define PVRSRV_HWPERF_COUNTERS_PERBLK 12
#define RELEASE
#define RGX_BVNC_CORE_KM_HEADER "cores/rgxcore_km_36.52.104.182.h"
#define RGX_BNC_CONFIG_KM_HEADER "configs/rgxconfig_km_36.V.104.182.h"
#define PVRSRV_ENABLE_XD_MEM
#define PVRSRV_NEED_PVR_DPF
#define PVRSRV_TRACE_ROGUE_EVENTS
#define SUPPORT_PHYSMEM_TEST
#define PVRSRV_PHYSHEAP_ENABLE_GPUPRIVATE_PROMOTION
#define SUPPORT_RGXTQ_BRIDGE
#define PVRSRV_POISON_ON_ALLOC_VALUE 0xd9
#define PVRSRV_POISON_ON_FREE_VALUE 0x63
#define RGX_NUM_DRIVERS_SUPPORTED 1
#define RGX_HCS_DEFAULT_DEADLINE_MS 0xFFFFFFFFU
#define RGX_FW_HEAP_USES_FIRMWARE_OSID 0
#define RGX_FW_HEAP_USES_HOST_OSID 1
#define RGX_FW_HEAP_USES_DEDICATED_OSID 2
#define RGX_FW_HEAP_OSID_ASSIGNMENT RGX_FW_HEAP_USES_FIRMWARE_OSID
#define PVRSRV_APPHINT_PHYSHEAPMINMEMONCONNECTION 0
#define RGX_FW_PHYSHEAP_MINMEM_ON_CONNECTION 512
#define PVRSRV_APPHINT_DRIVERMODE "default"
#define RGX_FW_HEAP_SHIFT 25
#define PVRSRV_APPHINT_GUESTFWHEAPSTRIDE (1 << RGX_FW_HEAP_SHIFT)
#define PVRSRV_APPHINT_AUTOVZGPUPOWERDOWN IMG_FALSE
#define RGX_VZ_CONNECTION_TIMEOUT_US 60000000
#define PVRSRV_MAX_REAL_TIME_CONTEXTS 1
#define GPUVIRT_VALIDATION_NUM_OS 8
#define PVRSRV_ENABLE_CCCB_GROW
#define SUPPORT_POWMON_COMPONENT
#define PVR_POWER_ACTOR_MEASUREMENT_PERIOD_MS 10U
#define PVR_POWER_MONITOR_HWPERF
#define PVR_LDM_PLATFORM_PRE_REGISTERED
#define PVR_LDM_DRIVER_REGISTRATION_NAME "pvrsrvkm"
#define PVRSRV_FULL_SYNC_TRACKING_HISTORY_LEN 256
#define ION_DEFAULT_HEAP_NAME "ion_system_heap"
#define ION_DEFAULT_HEAP_ID_MASK (1 << ION_HEAP_TYPE_SYSTEM)
#define SUPPORT_SOC_TIMER
#define PVRSRV_APPHINT_HWRDEBUGDUMPLIMIT APPHNT_BLDVAR_DBGDUMPLIMIT
#define PVRSRV_APPHINT_ENABLETRUSTEDDEVICEACECONFIG IMG_FALSE
#define PVRSRV_APPHINT_GENERALNON4KHEAPPAGESIZE 0x4000
#define PVRSRV_APPHINT_HWPERFCLIENTBUFFERSIZE 786432
#define PVRSRV_APPHINT_ENABLESIGNATURECHECKS APPHNT_BLDVAR_ENABLESIGNATURECHECKS
#define PVRSRV_APPHINT_SIGNATURECHECKSBUFSIZE RGXFW_SIG_BUFFER_SIZE_MIN
#define PVRSRV_APPHINT_ENABLEFULLSYNCTRACKING IMG_FALSE
#define PVRSRV_APPHINT_ENABLEPAGEFAULTDEBUG APPHNT_BLDVAR_ENABLEPAGEFAULTDEBUG
#define PVRSRV_APPHINT_VALIDATEIRQ 0
#define PVRSRV_APPHINT_DISABLECLOCKGATING 0
#define PVRSRV_APPHINT_DISABLEDMOVERLAP 0
#define PVRSRV_APPHINT_ENABLECDMKILLINGRANDMODE 0
#define PVRSRV_APPHINT_ENABLERANDOMCONTEXTSWITCH 0
#define PVRSRV_APPHINT_ENABLESOFTRESETCONTEXTSWITCH 0
#define PVRSRV_APPHINT_ENABLEFWCONTEXTSWITCH RGXFWIF_INICFG_OS_CTXSWITCH_DM_ALL
#define PVRSRV_APPHINT_ENABLERDPOWERISLAND RGX_RD_POWER_ISLAND_DEFAULT
#define PVRSRV_APPHINT_ENABLESPUCLOCKGATING IMG_FALSE
#define PVRSRV_APPHINT_FIRMWAREPERF FW_PERF_CONF_NONE
#define PVRSRV_APPHINT_FWCONTEXTSWITCHPROFILE RGXFWIF_CTXSWITCH_PROFILE_MEDIUM_EN
#define PVRSRV_APPHINT_HWPERFDISABLECUSTOMCOUNTERFILTER 0
#define PVRSRV_APPHINT_HWPERFFWBUFSIZEINKB 2048
#define PVRSRV_APPHINT_HWPERFHOSTBUFSIZEINKB 2048
#define PVRSRV_APPHINT_HWPERFHOSTTHREADTIMEOUTINMS 50
#define PVRSRV_APPHINT_TFBCCOMPRESSIONCONTROLGROUP 1
#define PVRSRV_APPHINT_TFBCCOMPRESSIONCONTROLSCHEME 0
#define PVRSRV_APPHINT_TFBCVERSION 0
#define PVRSRV_APPHINT_NEWFILTERINGMODE 1
#define PVRSRV_APPHINT_TRUNCATEMODE 0
#define PVRSRV_APPHINT_EMUMAXFREQ 0
#define PVRSRV_APPHINT_GPIOVALIDATIONMODE 0
#define PVRSRV_APPHINT_RGXBVNC ""
#define PVRSRV_APPHINT_CLEANUPTHREADPRIORITY 5
#define PVRSRV_APPHINT_WATCHDOGTHREADPRIORITY 0
#define PVRSRV_APPHINT_CACHEOPTHREADPRIORITY 1
#define PVRSRV_APPHINT_DEVMEM_HISTORY_BUFSIZE_LOG2 11
#define PVRSRV_APPHINT_DEVMEM_HISTORY_MAX_ENTRIES 10000
#define PVRSRV_APPHINT_ASSERTONHWRTRIGGER IMG_FALSE
#define PVRSRV_APPHINT_ASSERTOUTOFMEMORY IMG_FALSE
#define PVRSRV_APPHINT_CHECKMLIST APPHNT_BLDVAR_DEBUG
#define PVRSRV_APPHINT_DISABLEFEDLOGGING IMG_FALSE
#define PVRSRV_APPHINT_KCCB_SIZE_LOG2 10
#define PVRSRV_APPHINT_ENABLEAPM RGX_ACTIVEPM_DEFAULT
#define PVRSRV_APPHINT_ENABLEHTBLOGGROUP 0
#define PVRSRV_APPHINT_ENABLELOGGROUP RGXFWIF_LOG_TYPE_NONE
#define PVRSRV_APPHINT_FIRMWARELOGTYPE 0
#define PVRSRV_APPHINT_FWTRACEBUFSIZEINDWORDS RGXFW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS
#define PVRSRV_APPHINT_DEBUGDUMPFWTLOGTYPE 1
#define PVRSRV_APPHINT_ENABLEIDLECYCLESTEALING 0
#define PVRSRV_APPHINT_FAULTDETECTIONTIMEINTERVAL_USEC 40000
#define PVRSRV_APPHINT_ICSTIMEINTERVAL_THRESHOLD 90
#define PVRSRV_APPHINT_FBCDCVERSIONOVERRIDE 0
#define PVRSRV_APPHINT_HTBOPERATIONMODE HTB_OPMODE_DROPOLDEST
#define PVRSRV_APPHINT_HTBUFFERSIZE 64
#define PVRSRV_APPHINT_ENABLEFTRACEGPU IMG_FALSE
#define PVRSRV_APPHINT_HWPERFFWFILTER 0
#define PVRSRV_APPHINT_HWPERFHOSTFILTER 0
#define PVRSRV_APPHINT_HWPERFCLIENTFILTER_SERVICES 0
#define PVRSRV_APPHINT_HWPERFCLIENTFILTER_EGL 0
#define PVRSRV_APPHINT_HWPERFCLIENTFILTER_OPENGLES 0
#define PVRSRV_APPHINT_HWPERFCLIENTFILTER_OPENCL 0
#define PVRSRV_APPHINT_HWPERFCLIENTFILTER_VULKAN 0
#define PVRSRV_APPHINT_HWPERFCLIENTFILTER_OPENGL 0
#define PVRSRV_APPHINT_SECONDARYOSCLOCKSOURCE 2
#define PVRSRV_APPHINT_ENABLEFWPOISONONFREE IMG_FALSE
#define PVRSRV_APPHINT_FWPOISONONFREEVALUE 0xBD
#define PVRSRV_APPHINT_ZEROFREELIST IMG_FALSE
#define PVRSRV_APPHINT_GPUUNITSPOWERCHANGE IMG_FALSE
#define PVRSRV_APPHINT_DISABLEPDUMPPANIC IMG_FALSE
#define PVRSRV_APPHINT_CACHEOPCONFIG 0
#define PVRSRV_APPHINT_CACHEOPUMKMHRESHOLDSIZE 0
#define PVRSRV_APPHINT_IGNOREHWREPORTEDBVNC IMG_FALSE
#define PVRSRV_APPHINT_PHYSMEMTESTPASSES APPHNT_PHYSMEMTEST_ENABLE
#define PVRSRV_APPHINT_TESTSLRINTERVAL 0
#define PVRSRV_APPHINT_RISCVDMITEST 0
#define PVRSRV_APPHINT_VALIDATESOCUSCTIMERS 0
#define PVRSRV_APPHINT_CHECKPOINTPOOLMAXLOG2 8
#define PVRSRV_APPHINT_CHECKPOINTPOOLINITLOG2 7
#define PDVFS_COM_HOST 1
#define PDVFS_COM_AP 2
#define PDVFS_COM_PMC 3
#define PDVFS_COM_IMG_CLKDIV 4
#define PDVFS_COM_SYSREG 5
#define PDVFS_COM PDVFS_COM_HOST
#define SUPPORT_FW_CORE_CLK_RATE_CHANGE_NOTIFY
#define SUPPORT_PVR_GPIO 1
#define PVRSRV_ENABLE_PROCESS_STATS
#define SUPPORT_USC_BREAKPOINT
#define SUPPORT_AGP
#define RGXFW_SAFETY_WATCHDOG_PERIOD_IN_US 2000000
#define PVR_ANNOTATION_MAX_LEN 63
#define PVRSRV_DEVICE_INIT_MODE PVRSRV_LINUX_DEV_INIT_ON_CONNECT
#define SUPPORT_DI_APPHINT_IMPL
#define PVR_LINUX_PHYSMEM_MAX_POOL_PAGES 10240
#define PVR_LINUX_PHYSMEM_MAX_EXCESS_POOL_PAGES 20480
#define PVR_PHYSMEM_ZERO_ALL_PAGES
#define PVR_DIRTY_BYTES_FLUSH_THRESHOLD 524288
#define PVR_LINUX_HIGHORDER_ALLOCATION_THRESHOLD 256
#define PVR_LINUX_PHYSMEM_MAX_ALLOC_ORDER_NUM 2
#define PVR_LINUX_KMALLOC_ALLOCATION_THRESHOLD 16384
#define SUPPORT_PMR_DEFERRED_FREE
#define SUPPORT_PMR_PAGES_DEFERRED_FREE
#define SUPPORT_PMR_DEVICE_IMPORT_DEFERRED_FREE
#define SUPPORT_MMU_DEFERRED_FREE
#define SUPPORT_WRAP_EXTMEM
#define PVRSRV_USE_LINUX_CONFIG_INIT_ON_ALLOC 1
#define SUPPORT_NATIVE_FENCE_SYNC
#define PVRSRV_STALLED_CCB_ACTION
#define UPDATE_FENCE_CHECKPOINT_COUNT 1
#define RGX_VZ_CONNECTION_COOLDOWN_PERIOD 0
#define PVR_DRM_NAME "pvr"
#define DEVICE_MEMSETCPY_ALIGN_IN_BYTES 16
#define DISABLE_GPU_FREQUENCY_CALIBRATION
#define RGX_INITIAL_SLR_HOLDOFF_PERIOD_MS 0
#define PVRSRV_RGX_LOG2_CLIENT_CCB_SIZE_TQ3D 14
#define PVRSRV_RGX_LOG2_CLIENT_CCB_SIZE_TQ2D 14
#define PVRSRV_RGX_LOG2_CLIENT_CCB_SIZE_CDM 13
#define PVRSRV_RGX_LOG2_CLIENT_CCB_SIZE_TA 15
#define PVRSRV_RGX_LOG2_CLIENT_CCB_SIZE_3D 16
#define PVRSRV_RGX_LOG2_CLIENT_CCB_SIZE_KICKSYNC 13
#define PVRSRV_RGX_LOG2_CLIENT_CCB_SIZE_TDM 14
#define PVRSRV_RGX_LOG2_CLIENT_CCB_SIZE_RDM 13
#define PVRSRV_RGX_LOG2_CLIENT_CCB_MAX_SIZE_TQ3D 17
#define PVRSRV_RGX_LOG2_CLIENT_CCB_MAX_SIZE_TQ2D 17
#define PVRSRV_RGX_LOG2_CLIENT_CCB_MAX_SIZE_CDM 15
#define PVRSRV_RGX_LOG2_CLIENT_CCB_MAX_SIZE_TA 16
#define PVRSRV_RGX_LOG2_CLIENT_CCB_MAX_SIZE_3D 17
#define PVRSRV_RGX_LOG2_CLIENT_CCB_MAX_SIZE_KICKSYNC 13
#define PVRSRV_RGX_LOG2_CLIENT_CCB_MAX_SIZE_TDM 17
#define PVRSRV_RGX_LOG2_CLIENT_CCB_MAX_SIZE_RDM 15
#define RGX_DRIVERID_0_DEFAULT_PRIORITY (1 - 0)
#define RGX_DRIVERID_1_DEFAULT_PRIORITY (1 - 1)
#define RGX_DRIVERID_2_DEFAULT_PRIORITY (1 - 2)
#define RGX_DRIVERID_3_DEFAULT_PRIORITY (1 - 3)
#define RGX_DRIVERID_4_DEFAULT_PRIORITY (1 - 4)
#define RGX_DRIVERID_5_DEFAULT_PRIORITY (1 - 5)
#define RGX_DRIVERID_6_DEFAULT_PRIORITY (1 - 6)
#define RGX_DRIVERID_7_DEFAULT_PRIORITY (1 - 7)
#define RGX_DRIVERID_8_DEFAULT_PRIORITY (1 - 8)
#define RGX_DRIVERID_9_DEFAULT_PRIORITY (1 - 9)
#define RGX_DRIVERID_10_DEFAULT_PRIORITY (1 - 10)
#define RGX_DRIVERID_11_DEFAULT_PRIORITY (1 - 11)
#define RGX_DRIVERID_12_DEFAULT_PRIORITY (1 - 12)
#define RGX_DRIVERID_13_DEFAULT_PRIORITY (1 - 13)
#define RGX_DRIVERID_14_DEFAULT_PRIORITY (1 - 14)
#define RGX_DRIVERID_15_DEFAULT_PRIORITY (1 - 15)
#define RGX_DRIVERID_16_DEFAULT_PRIORITY (1 - 16)
#define RGX_DRIVERID_17_DEFAULT_PRIORITY (1 - 17)
#define RGX_DRIVERID_18_DEFAULT_PRIORITY (1 - 18)
#define RGX_DRIVERID_19_DEFAULT_PRIORITY (1 - 19)
#define RGX_DRIVERID_20_DEFAULT_PRIORITY (1 - 20)
#define RGX_DRIVERID_21_DEFAULT_PRIORITY (1 - 21)
#define RGX_DRIVERID_22_DEFAULT_PRIORITY (1 - 22)
#define RGX_DRIVERID_23_DEFAULT_PRIORITY (1 - 23)
#define RGX_DRIVERID_24_DEFAULT_PRIORITY (1 - 24)
#define RGX_DRIVERID_25_DEFAULT_PRIORITY (1 - 25)
#define RGX_DRIVERID_26_DEFAULT_PRIORITY (1 - 26)
#define RGX_DRIVERID_27_DEFAULT_PRIORITY (1 - 27)
#define RGX_DRIVERID_28_DEFAULT_PRIORITY (1 - 28)
#define RGX_DRIVERID_29_DEFAULT_PRIORITY (1 - 29)
#define RGX_DRIVERID_30_DEFAULT_PRIORITY (1 - 30)
#define RGX_DRIVERID_31_DEFAULT_PRIORITY (1 - 31)
#define RGX_DRIVERID_0_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_1_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_2_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_3_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_4_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_5_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_6_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_7_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_8_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_9_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_10_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_11_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_12_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_13_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_14_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_15_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_16_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_17_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_18_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_19_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_20_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_21_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_22_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_23_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_24_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_25_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_26_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_27_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_28_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_29_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_30_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_31_DEFAULT_ISOLATION_GROUP 0
#define RGX_DRIVERID_0_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_1_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_2_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_3_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_4_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_5_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_6_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_7_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_8_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_9_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_10_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_11_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_12_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_13_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_14_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_15_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_16_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_17_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_18_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_19_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_20_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_21_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_22_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_23_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_24_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_25_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_26_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_27_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_28_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_29_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_30_DEFAULT_TIME_SLICE 0
#define RGX_DRIVERID_31_DEFAULT_TIME_SLICE 0
#define RGX_DRIVER_DEFAULT_TIME_SLICE_INTERVAL 0
#define RGX_DRIVER_DEFAULT_TIME_SLICES_SUM (((((((((((((((((((((((((((((((( + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0) + 0)
#define DRIVER0_SECURITY_SUPPORT 0
#define DRIVER1_SECURITY_SUPPORT 0
#define DRIVER2_SECURITY_SUPPORT 0
#define DRIVER3_SECURITY_SUPPORT 0
#define DRIVER4_SECURITY_SUPPORT 0
#define DRIVER5_SECURITY_SUPPORT 0
#define DRIVER6_SECURITY_SUPPORT 0
#define DRIVER7_SECURITY_SUPPORT 0
#define DRIVER8_SECURITY_SUPPORT 0
#define DRIVER9_SECURITY_SUPPORT 0
#define DRIVER10_SECURITY_SUPPORT 0
#define DRIVER11_SECURITY_SUPPORT 0
#define DRIVER12_SECURITY_SUPPORT 0
#define DRIVER13_SECURITY_SUPPORT 0
#define DRIVER14_SECURITY_SUPPORT 0
#define DRIVER15_SECURITY_SUPPORT 0
#define DRIVER16_SECURITY_SUPPORT 0
#define DRIVER17_SECURITY_SUPPORT 0
#define DRIVER18_SECURITY_SUPPORT 0
#define DRIVER19_SECURITY_SUPPORT 0
#define DRIVER20_SECURITY_SUPPORT 0
#define DRIVER21_SECURITY_SUPPORT 0
#define DRIVER22_SECURITY_SUPPORT 0
#define DRIVER23_SECURITY_SUPPORT 0
#define DRIVER24_SECURITY_SUPPORT 0
#define DRIVER25_SECURITY_SUPPORT 0
#define DRIVER26_SECURITY_SUPPORT 0
#define DRIVER27_SECURITY_SUPPORT 0
#define DRIVER28_SECURITY_SUPPORT 0
#define DRIVER29_SECURITY_SUPPORT 0
#define DRIVER30_SECURITY_SUPPORT 0
#define DRIVER31_SECURITY_SUPPORT 0
#define SUPPORT_BUFFER_SYNC 1

View File

@@ -0,0 +1,51 @@
override PVRSRV_DIR := services
override HOST_PRIMARY_ARCH := host_x86_64
override TARGET_PRIMARY_ARCH := target_riscv64
override TARGET_SECONDARY_ARCH :=
override TARGET_ALL_ARCH := target_riscv64
override TARGET_FORCE_32BIT :=
override PVR_ARCH := rogue
override METAG_VERSION_NEEDED := 2.8.1.0.3
override MIPS_VERSION_NEEDED := 2014.07-1
override RISCV_VERSION_NEEDED := 2024.1.0
override KERNELDIR := /home/icenowy/builds/linux/th1520
override KERNEL_ID := 6.6.113-th1520+
override PVRSRV_MODULE_BASEDIR := /lib/modules/6.6.113-th1520+/extra/
override KERNEL_COMPONENTS := srvkm drm_nulldisp
override KERNEL_CROSS_COMPILE := /opt/abcross/riscv64/bin/riscv64-aosc-linux-gnu-
override WINDOW_SYSTEM := wayland
override PVRSRV_MODNAME := pvrsrvkm
override PVR_BUILD_DIR := xuantie_linux
override PVR_BUILD_TYPE := release
override SUPPORT_RGX := 1
override DISPLAY_CONTROLLER := drm_nulldisp
override PVR_SYSTEM := rgx_xuantie
override PVR_LOADER :=
override BUILD := release
override SORT_BRIDGE_STRUCTS := 1
override DEBUGLINK := 1
override RGX_BNC := 36.V.104.182
override PVRSRV_ENABLE_XD_MEM := 1
override PVRSRV_TRACE_ROGUE_EVENTS := 1
override SUPPORT_PHYSMEM_TEST := 1
override SUPPORT_MIPS_64K_PAGE_SIZE :=
override RGX_NUM_DRIVERS_SUPPORTED := 1
override RGX_FW_HEAP_OSID_ASSIGNMENT := RGX_FW_HEAP_USES_FIRMWARE_OSID
override VMM_TYPE := stub
override SUPPORT_POWMON_COMPONENT := 1
override RGX_SECONDARY_OS_CLOCK_SOURCE := sched
override PDVFS_COM_HOST := 1
override PDVFS_COM_AP := 2
override PDVFS_COM_PMC := 3
override PDVFS_COM_IMG_CLKDIV := 4
override PDVFS_COM_SYSREG := 5
override PDVFS_COM := PDVFS_COM_HOST
override SUPPORT_FW_CORE_CLK_RATE_CHANGE_NOTIFY := 1
override SUPPORT_PVR_GPIO := 1
override PVR_HANDLE_BACKEND := idr
override SUPPORT_DMABUF_BRIDGE := 1
override SUPPORT_USC_BREAKPOINT := 1
override SUPPORT_DI_APPHINT_IMPL := 1
override SUPPORT_WRAP_EXTMEM := 1
override SUPPORT_NATIVE_FENCE_SYNC := 1
override SUPPORT_BUFFER_SYNC := 1

View File

@@ -0,0 +1,107 @@
/*************************************************************************/ /*!
@Title RGX Configuration for BVNC 36.V.104.182 (kernel defines)
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef RGXCONFIG_KM_36_V_104_182_H
#define RGXCONFIG_KM_36_V_104_182_H
/***** Automatically generated file. Do not edit manually ********************/
/******************************************************************************
* B.V.N.C Validation defines
*****************************************************************************/
#define RGX_BNC_KM_B 36
#define RGX_BNC_KM_N 104
#define RGX_BNC_KM_C 182
/******************************************************************************
* DDK Defines
*****************************************************************************/
#define RGX_FEATURE_AXI_ACELITE
#define RGX_FEATURE_CDM_CONTROL_STREAM_FORMAT (1U)
#define RGX_FEATURE_COMPUTE
#define RGX_FEATURE_COMPUTE_OVERLAP
#define RGX_FEATURE_COREID_PER_OS
#define RGX_FEATURE_FAULT_DECODE_VERSION (0U)
#define RGX_FEATURE_FBCDC (50U)
#define RGX_FEATURE_FBCDC_ALGORITHM (50U)
#define RGX_FEATURE_FBCDC_ARCHITECTURE (7U)
#define RGX_FEATURE_FBC_MAX_DEFAULT_DESCRIPTORS (0U)
#define RGX_FEATURE_FBC_MAX_LARGE_DESCRIPTORS (0U)
#define RGX_FEATURE_GPU_MULTICORE_SUPPORT
#define RGX_FEATURE_GPU_VIRTUALISATION
#define RGX_FEATURE_GS_RTA_SUPPORT
#define RGX_FEATURE_IRQ_PER_OS
#define RGX_FEATURE_LAYOUT_MARS (1U)
#define RGX_FEATURE_MIPS
#define RGX_FEATURE_NUM_CLUSTERS (1U)
#define RGX_FEATURE_NUM_ISP_IPP_PIPES (6U)
#define RGX_FEATURE_NUM_OSIDS (8U)
#define RGX_FEATURE_NUM_RASTER_PIPES (1U)
#define RGX_FEATURE_PBE2_IN_XE
#define RGX_FEATURE_PBVNC_COREID_REG
#define RGX_FEATURE_PERFBUS
#define RGX_FEATURE_PHYS_BUS_WIDTH (36U)
#define RGX_FEATURE_ROGUEXE
#define RGX_FEATURE_SIMPLE_INTERNAL_PARAMETER_FORMAT
#define RGX_FEATURE_SIMPLE_INTERNAL_PARAMETER_FORMAT_V2
#define RGX_FEATURE_SIMPLE_PARAMETER_FORMAT_VERSION (2U)
#define RGX_FEATURE_SLC_BANKS (1U)
#define RGX_FEATURE_SLC_CACHE_LINE_SIZE_BITS (512U)
#define RGX_FEATURE_SLC_SIZE_CONFIGURABLE /* Specifies the SLC is */
/* customer-configurable. True SLC */
/* size must be sourced from */
/* register. */
#define RGX_FEATURE_SLC_SIZE_IN_KILOBYTES (16U)
#define RGX_FEATURE_SOC_TIMER
#define RGX_FEATURE_SYS_BUS_SECURE_RESET
#define RGX_FEATURE_TFBC_VERSION (10U)
#define RGX_FEATURE_TILE_SIZE_X (16U)
#define RGX_FEATURE_TILE_SIZE_Y (16U)
#define RGX_FEATURE_TPU_CEM_DATAMASTER_GLOBAL_REGISTERS
#define RGX_FEATURE_TPU_DM_GLOBAL_REGISTERS
#define RGX_FEATURE_VIRTUAL_ADDRESS_SPACE_BITS (40U)
#define RGX_FEATURE_XE_ARCHITECTURE (1U)
#define RGX_FEATURE_XE_MEMORY_HIERARCHY
#define RGX_FEATURE_XPU_MAX_REGBANKS_ADDR_WIDTH (19U)
#define RGX_FEATURE_XPU_MAX_SLAVES (3U)
#define RGX_FEATURE_XPU_REGISTER_BROADCAST (1U)
#endif /* RGXCONFIG_KM_36_V_104_182_H */

View File

@@ -0,0 +1,529 @@
/*************************************************************************/ /*!
@File
@Title Server side connection management
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Handles connections coming from the client and the management
connection based information
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#include "handle.h"
#include "pvrsrv.h"
#include "connection_server.h"
#include "osconnection_server.h"
#include "allocmem.h"
#include "pvr_debug.h"
#include "sync_server.h"
#include "process_stats.h"
#include "pdump_km.h"
#include "osfunc.h"
#include "tlstream.h"
#include "tlintern.h"
#include "rgxhwperf_common.h"
#if defined(PVRSRV_ENABLE_GPU_MEMORY_INFO)
#include "ri_server.h"
#endif
/* Set the maximum time the CleanupThread should retry destroying resources
* associated with a connection before giving up.
* This value is derived from MAX_HW_TIME_US which on a normal system is
* usually between 500 to 1000ms, so the below formula should give us time
* between 2 to 4 minutes on most of the systems. */
#define CONNECTION_CLEANUP_RETRY_TIMEOUT_MS (MAX_HW_TIME_US / 1000 * 240)
/* PID associated with Connection currently being purged by Cleanup thread */
static IMG_PID gCurrentPurgeConnectionPid;
static PVRSRV_ERROR ConnectionDataDestroy(CONNECTION_DATA *psConnection)
{
PVRSRV_ERROR eError;
PROCESS_HANDLE_BASE *psProcessHandleBase;
IMG_UINT64 ui64MaxBridgeTime;
PVRSRV_DATA *psPVRSRVData = PVRSRVGetPVRSRVData();
PVRSRV_DEVICE_NODE *psDevNode = OSGetDevNode(psConnection);
if (psPVRSRVData->bUnload)
{
/* driver is unloading so do not allow the bridge lock to be released */
ui64MaxBridgeTime = 0;
}
else
{
ui64MaxBridgeTime = CONNECTION_DEFERRED_CLEANUP_TIMESLICE_NS;
}
PVR_ASSERT(psConnection != NULL);
PVR_LOG_RETURN_IF_INVALID_PARAM(psConnection, "psConnection");
/* Close HWPerfClient stream here even though we created it in
* PVRSRVConnectKM(). */
if (psConnection->hClientTLStream)
{
TLStreamClose(psConnection->hClientTLStream);
psConnection->hClientTLStream = NULL;
PVR_DPF((PVR_DBG_MESSAGE, "Destroyed private stream."));
}
if (psConnection->ui32ClientFlags & SRV_FLAGS_HWPERF_DEFERRED_DESTROY)
{
TLDeactivateDeferredFree();
}
/* Get process handle base to decrement the refcount */
/* Get process handle base to decrement the refcount */
psProcessHandleBase = psConnection->psProcessHandleBase;
if (psProcessHandleBase != NULL)
{
/* PVRSRVReleaseProcessHandleBase() calls PVRSRVFreeKernelHandles()
* and PVRSRVFreeHandleBase() for the process handle base.
* Releasing kernel handles can never return RETRY error because
* release function for those handles are NOPs and PVRSRVFreeKernelHandles()
* doesn't even call pfnReleaseData() callback.
* Process handles can potentially return RETRY hence additional check
* below. */
eError = PVRSRVReleaseProcessHandleBase(psProcessHandleBase,
ui64MaxBridgeTime);
if (PVRSRVIsRetryError(eError))
{
return eError;
}
else
{
PVR_LOG_RETURN_IF_ERROR(eError, "PVRSRVReleaseProcessHandleBase");
}
psConnection->psProcessHandleBase = NULL;
}
/* Free handle base for this connection */
if (psConnection->psHandleBase != NULL)
{
eError = PVRSRVFreeHandleBase(psConnection->psHandleBase, ui64MaxBridgeTime);
/*
* If we get PVRSRV_ERROR_RETRY we need to pass this back to the caller
* who will schedule a retry.
* Do not log this as it is an expected exception.
* This can occur if the Firmware is still processing a workload from
* the client when a tear-down request is received.
* Retrying will allow the in-flight work to be completed and the
* tear-down request can be completed when the FW is no longer busy.
*/
if (PVRSRVIsRetryError(eError))
{
return eError;
}
else
{
PVR_LOG_RETURN_IF_ERROR(eError, "PVRSRVFreeHandleBase");
}
psConnection->psHandleBase = NULL;
}
if (psConnection->psSyncConnectionData != NULL)
{
SyncUnregisterConnection(psConnection->psSyncConnectionData);
psConnection->psSyncConnectionData = NULL;
}
if (psConnection->psPDumpConnectionData != NULL)
{
PDumpUnregisterConnection(psDevNode,
psConnection->psPDumpConnectionData);
psConnection->psPDumpConnectionData = NULL;
}
#if defined(PVRSRV_ENABLE_PROCESS_STATS)
PVRSRVStatsDeviceDisconnect(psDevNode);
#endif
/* Call environment specific connection data deinit function */
if (psConnection->hOsPrivateData != NULL)
{
eError = OSConnectionPrivateDataDeInit(psConnection->hOsPrivateData);
PVR_LOG_RETURN_IF_ERROR(eError, "OSConnectionPrivateDataDeInit");
psConnection->hOsPrivateData = NULL;
}
/* Close the PID stats entry as late as possible to catch all frees */
#if defined(PVRSRV_ENABLE_PROCESS_STATS) && !defined(PVRSRV_DEBUG_LINUX_MEMORY_STATS)
if (psConnection->hProcessStats != NULL)
{
PVRSRVStatsDeregisterProcess(psConnection->hProcessStats);
psConnection->hProcessStats = NULL;
}
#endif
OSFreeMemNoStats(psConnection);
#if defined(SUPPORT_PMR_DEFERRED_FREE)
/* Kick the Firmware to invalidate caches to clear all the zombie PMRs.
* If there are not zombie PMRs or no mappings were freed the kick will not
* be executed.
*
* This is needed:
* - when the process is killed and the connection cleanup has to clean up
* all dangling handles.
* - there are any outstanding PMRs in the zombie list due to no
* invalidation being executed before connection destruction
*/
eError = MMU_CacheInvalidateKick(psDevNode, NULL);
PVR_LOG_IF_ERROR(eError, "MMU_CacheInvalidateKick");
#endif /* defined(SUPPORT_PMR_DEFERRED_FREE) */
return PVRSRV_OK;
}
PVRSRV_ERROR PVRSRVCommonConnectionConnect(void **ppvPrivData, void *pvOSData)
{
CONNECTION_DATA *psConnection;
PVRSRV_ERROR eError;
PROCESS_HANDLE_BASE *psProcessHandleBase;
PVRSRV_DEVICE_NODE *psDevNode;
/* Allocate connection data area, no stats since process not registered yet */
psConnection = OSAllocZMemNoStats(sizeof(*psConnection));
PVR_LOG_RETURN_IF_NOMEM(psConnection, "psConnection");
/* Allocate process statistics as early as possible to catch all allocs */
#if defined(PVRSRV_ENABLE_PROCESS_STATS) && !defined(PVRSRV_DEBUG_LINUX_MEMORY_STATS)
eError = PVRSRVStatsRegisterProcess(&psConnection->hProcessStats);
PVR_LOG_GOTO_IF_ERROR(eError, "PVRSRVStatsRegisterProcess", failure);
#endif
/* Call environment specific connection data init function */
eError = OSConnectionPrivateDataInit(&psConnection->hOsPrivateData, pvOSData);
PVR_LOG_GOTO_IF_ERROR(eError, "OSConnectionPrivateDataInit", failure);
/* Must come after OSConnectionPrivateDataInit */
psDevNode = OSGetDevNode(psConnection);
PVR_LOG_GOTO_IF_NOMEM(psDevNode, eError, failure);
if (psDevNode->eDevState == PVRSRV_DEVICE_STATE_DEINIT ||
psDevNode->eDevState == PVRSRV_DEVICE_STATE_DESTRUCTING)
{
PVR_DPF((PVR_DBG_ERROR, "Cannot connect to the device during deinit"));
PVR_GOTO_WITH_ERROR(eError, PVRSRV_ERROR_INVALID_DEVICE, failure);
}
psConnection->pid = OSGetCurrentClientProcessIDKM();
psConnection->vpid = OSGetCurrentVirtualProcessID();
psConnection->tid = (IMG_UINT32)OSGetCurrentClientThreadIDKM();
OSStringSafeCopy(psConnection->pszProcName, OSGetCurrentClientProcessNameKM(), PVRSRV_CONNECTION_PROCESS_NAME_LEN);
#if defined(SUPPORT_DMA_TRANSFER)
eError = PVRSRVInitialiseDMA(psDevNode, psConnection);
PVR_LOG_GOTO_IF_ERROR(eError, "PVRSRVInitialiseDMA", failure);
#endif
/* Register this connection with the sync core */
eError = SyncRegisterConnection(&psConnection->psSyncConnectionData);
PVR_LOG_GOTO_IF_ERROR(eError, "SyncRegisterConnection", failure);
/*
* Register this connection and Sync PDump callback with
* the pdump core. Pass in the Sync connection data.
*/
eError = PDumpRegisterConnection(psDevNode,
psConnection->psSyncConnectionData,
SyncConnectionPDumpSyncBlocks,
&psConnection->psPDumpConnectionData);
PVR_LOG_GOTO_IF_ERROR(eError, "PDumpRegisterConnection", failure);
/* Allocate handle base for this connection */
eError = PVRSRVAllocHandleBase(&psConnection->psHandleBase,
PVRSRV_HANDLE_BASE_TYPE_CONNECTION);
PVR_LOG_GOTO_IF_ERROR(eError, "PVRSRVAllocHandleBase", failure);
/* get process handle base for the current process (if it doesn't exist it will be allocated) */
eError = PVRSRVAcquireProcessHandleBase(&psProcessHandleBase);
PVR_LOG_GOTO_IF_ERROR(eError, "PVRSRVAcquireProcessHandleBase", failure);
/* hConnectionsLock now resides in PVRSRV_DEVICE_NODE */
{
IMG_BOOL bHostStreamIsNull;
PVRSRV_RGXDEV_INFO *psRgxDevInfo;
#if defined(PVRSRV_ENABLE_PROCESS_STATS)
eError = PVRSRVStatsDeviceConnect(psDevNode);
PVR_LOG_GOTO_IF_ERROR(eError, "PVRSRVStatsDeviceConnect", failure);
#endif
OSLockAcquire(psDevNode->hConnectionsLock);
dllist_add_to_tail(&psDevNode->sConnections, &psConnection->sConnectionListNode);
#if defined(DEBUG) || defined(PDUMP)
PVR_LOG(("%s connected - (devID = %u)", psConnection->pszProcName,
psDevNode->sDevId.ui32InternalID));
#endif
OSLockRelease(psDevNode->hConnectionsLock);
if (!PVRSRV_VZ_MODE_IS(GUEST, DEVNODE, psDevNode))
{
psRgxDevInfo = _RGX_DEVICE_INFO_FROM_NODE(psDevNode);
OSLockAcquire(psRgxDevInfo->hLockHWPerfHostStream);
bHostStreamIsNull = (IMG_BOOL)(psRgxDevInfo->hHWPerfHostStream == NULL);
OSLockRelease(psRgxDevInfo->hLockHWPerfHostStream);
if (!bHostStreamIsNull)
{
if (TLStreamIsOpenForReading(psRgxDevInfo->hHWPerfHostStream))
{
/* Announce this client connection in the host stream, if event mask is set */
RGXSRV_HWPERF_HOST_CLIENT_INFO_PROCESS_NAME(psDevNode, psConnection->pid, psConnection->pszProcName);
}
}
}
}
psConnection->psProcessHandleBase = psProcessHandleBase;
*ppvPrivData = psConnection;
return PVRSRV_OK;
failure:
ConnectionDataDestroy(psConnection);
return eError;
}
static PVRSRV_ERROR _CleanupThreadPurgeConnectionData(void *pvConnectionData)
{
PVRSRV_ERROR eErrorConnection, eErrorKernel;
CONNECTION_DATA *psConnectionData = pvConnectionData;
gCurrentPurgeConnectionPid = psConnectionData->pid;
eErrorConnection = ConnectionDataDestroy(psConnectionData);
if (eErrorConnection != PVRSRV_OK)
{
if (PVRSRVIsRetryError(eErrorConnection))
{
PVR_DPF((PVR_DBG_MESSAGE, "%s: Failed to purge connection data %p "
"(deferring destruction)", __func__, psConnectionData));
}
}
else
{
PVR_DPF((PVR_DBG_MESSAGE, "%s: Connection data %p deferred destruction "
"finished", __func__, psConnectionData));
}
/* Check if possible resize the global handle base */
eErrorKernel = PVRSRVPurgeHandles(KERNEL_HANDLE_BASE);
PVR_LOG_IF_ERROR(eErrorKernel, "PVRSRVPurgeHandles");
gCurrentPurgeConnectionPid = 0;
return eErrorConnection;
}
void PVRSRVCommonConnectionDisconnect(void *pvDataPtr)
{
CONNECTION_DATA *psConnectionData = pvDataPtr;
PVRSRV_DEVICE_NODE *psDevNode = OSGetDevNode(psConnectionData);
OSLockAcquire(psDevNode->hConnectionsLock);
dllist_remove_node(&psConnectionData->sConnectionListNode);
OSLockRelease(psDevNode->hConnectionsLock);
/* Notify the PDump core if the pdump control client is disconnecting */
if (psConnectionData->ui32ClientFlags & SRV_FLAGS_PDUMPCTRL)
{
PDumpDisconnectionNotify(psDevNode);
}
/* Add a HOST_CLIENT_INFO event to match the one on connection */
if (!PVRSRV_VZ_MODE_IS(GUEST, DEVNODE, psDevNode))
{
IMG_BOOL bHostStreamIsNull;
PVRSRV_RGXDEV_INFO *psRgxDevInfo;
psRgxDevInfo = _RGX_DEVICE_INFO_FROM_NODE(psDevNode);
OSLockAcquire(psRgxDevInfo->hLockHWPerfHostStream);
bHostStreamIsNull = (IMG_BOOL)(psRgxDevInfo->hHWPerfHostStream == NULL);
OSLockRelease(psRgxDevInfo->hLockHWPerfHostStream);
if (!bHostStreamIsNull)
{
if (TLStreamIsOpenForReading(psRgxDevInfo->hHWPerfHostStream))
{
/* Announce this client connection in the host stream, if event mask is set */
RGXSRV_HWPERF_HOST_CLIENT_INFO_PROCESS_NAME(psDevNode, psConnectionData->pid, psConnectionData->pszProcName);
}
}
}
#if defined(PVRSRV_ENABLE_GPU_MEMORY_INFO)
/* Mark remaining resources for driver to free */
RIConnectionClosed(psConnectionData);
#endif
#if defined(SUPPORT_DMA_TRANSFER)
PVRSRVDeInitialiseDMA(psDevNode, psConnectionData);
#endif
#if defined(DEBUG) || defined(PDUMP)
PVR_LOG(("%s disconnected - (devID = %u)", psConnectionData->pszProcName,
psDevNode->sDevId.ui32InternalID));
#endif
#if defined(PVRSRV_FORCE_UNLOAD_IF_BAD_STATE)
if (PVRSRVGetPVRSRVData()->eServicesState == PVRSRV_SERVICES_STATE_OK)
#endif
{
/* Defer the release of the connection data */
psConnectionData->sCleanupThreadFn.pfnFree = _CleanupThreadPurgeConnectionData;
psConnectionData->sCleanupThreadFn.pvData = psConnectionData;
/* Some resources in HANDLE_BASE may need FW idle confirmation
* hence setting to TRUE to use the global EO for retries which is
* signalled by the device MISR */
psConnectionData->sCleanupThreadFn.bDependsOnHW = IMG_TRUE;
psConnectionData->sCleanupThreadFn.eCleanupType = PVRSRV_CLEANUP_TYPE_CONNECTION;
CLEANUP_THREAD_SET_RETRY_TIMEOUT(&psConnectionData->sCleanupThreadFn,
CONNECTION_CLEANUP_RETRY_TIMEOUT_MS);
PVRSRVCleanupThreadAddWork(psDevNode, &psConnectionData->sCleanupThreadFn);
}
}
IMG_PID PVRSRVGetPurgeConnectionPid(void)
{
return gCurrentPurgeConnectionPid;
}
/* Prefix for debug messages about Active Connections */
#define DEBUG_DUMP_CONNECTION_FORMAT_STR " P%d-V%d-T%d-%s,"
#define CONNECTIONS_PREFIX "Connections Device ID:%u(%d)"
#define MAX_CONNECTIONS_PREFIX (29)
#define MAX_DEBUG_DUMP_CONNECTION_STR_LEN (1+10+10+10+7+PVRSRV_CONNECTION_PROCESS_NAME_LEN)
#define MAX_DEBUG_DUMP_STRING_LEN (1+MAX_CONNECTIONS_PREFIX+(3*MAX_DEBUG_DUMP_CONNECTION_STR_LEN))
void PVRSRVConnectionDebugNotify(PVRSRV_DEVICE_NODE *psDevNode,
DUMPDEBUG_PRINTF_FUNC *pfnDumpDebugPrintf,
void *pvDumpDebugFile)
{
PDLLIST_NODE pNext, pNode;
/* We must check for an initialised device before accessing its mutex.
* The mutex is initialised as part of DeviceInitialize() which occurs
* on first access to the device node.
*/
if ((psDevNode->eDevState != PVRSRV_DEVICE_STATE_ACTIVE) &&
(psDevNode->eDevState != PVRSRV_DEVICE_STATE_FROZEN))
{
PVR_DUMPDEBUG_LOG("Connections: No Devices: No active connections");
return;
}
OSLockAcquire(psDevNode->hConnectionsLock);
if (dllist_is_empty(&psDevNode->sConnections))
{
PVR_DUMPDEBUG_LOG(CONNECTIONS_PREFIX " No active connections",
(unsigned char)psDevNode->sDevId.ui32InternalID,
(unsigned char)psDevNode->sDevId.i32KernelDeviceID);
}
else
{
IMG_CHAR sActiveConnections[MAX_DEBUG_DUMP_STRING_LEN];
IMG_UINT16 i, uiPos = 0;
IMG_BOOL bPrinted = IMG_FALSE;
size_t uiSize = sizeof(sActiveConnections);
IMG_CHAR szTmpConBuff[MAX_CONNECTIONS_PREFIX + 1];
i = OSSNPrintf(szTmpConBuff,
MAX_CONNECTIONS_PREFIX,
CONNECTIONS_PREFIX,
(unsigned char)psDevNode->sDevId.ui32InternalID,
(unsigned char)psDevNode->sDevId.i32KernelDeviceID);
OSStringSafeCopy(sActiveConnections+uiPos, szTmpConBuff, uiSize);
/* Move the write offset to the end of the current string */
uiPos += i;
/* Update the amount of remaining space available to copy into */
uiSize -= i;
dllist_foreach_node(&psDevNode->sConnections, pNode, pNext)
{
CONNECTION_DATA *sData = IMG_CONTAINER_OF(pNode, CONNECTION_DATA, sConnectionListNode);
IMG_CHAR sTmpBuff[MAX_DEBUG_DUMP_CONNECTION_STR_LEN];
i = OSSNPrintf(sTmpBuff, MAX_DEBUG_DUMP_CONNECTION_STR_LEN,
DEBUG_DUMP_CONNECTION_FORMAT_STR, sData->pid, sData->vpid, sData->tid, sData->pszProcName);
i = MIN(MAX_DEBUG_DUMP_CONNECTION_STR_LEN, i);
bPrinted = IMG_FALSE;
OSStringSafeCopy(sActiveConnections+uiPos, sTmpBuff, uiSize);
/* Move the write offset to the end of the current string */
uiPos += i;
/* Update the amount of remaining space available to copy into */
uiSize -= i;
/* If there is not enough space to add another connection to this line, output the line */
if (uiSize <= MAX_DEBUG_DUMP_CONNECTION_STR_LEN)
{
PVR_DUMPDEBUG_LOG("%s", sActiveConnections);
/*
* Remove the "Connections:" prefix from the buffer.
* Leave the subsequent buffer contents indented by the same
* amount to aid in interpreting the debug output.
*/
uiPos = sizeof(CONNECTIONS_PREFIX) - 1;
/* Reset the amount of space available to copy into */
uiSize = MAX_DEBUG_DUMP_STRING_LEN - uiPos;
bPrinted = IMG_TRUE;
}
}
/* Only print the current line if it hasn't already been printed */
if (!bPrinted)
{
/* Strip off the final comma */
sActiveConnections[OSStringNLength(sActiveConnections, MAX_DEBUG_DUMP_STRING_LEN) - 1] = '\0';
PVR_DUMPDEBUG_LOG("%s", sActiveConnections);
}
#undef MAX_DEBUG_DUMP_STRING_LEN
#undef MAX_DEBUG_DUMP_CONNECTIONS_PER_LINE
}
OSLockRelease(psDevNode->hConnectionsLock);
}

View File

@@ -0,0 +1,143 @@
/*************************************************************************/ /*!
@File
@Title Server side connection management
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description API for server side connection management
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#if !defined(CONNECTION_SERVER_H)
#define CONNECTION_SERVER_H
#include "img_types.h"
#include "img_defs.h"
#include "handle.h"
#include "pvrsrv_cleanup.h"
/* Variable used to hold in memory the timeout for the current time slice*/
extern IMG_UINT64 gui64TimesliceLimit;
/* Counter number of handle data freed during the current time slice */
extern IMG_UINT32 gui32HandleDataFreeCounter;
/* Set the maximum time the freeing of the resources can keep the lock */
#define CONNECTION_DEFERRED_CLEANUP_TIMESLICE_NS (3000 * 1000) /* 3ms */
typedef struct _CONNECTION_DATA_
{
PVRSRV_HANDLE_BASE *psHandleBase;
PROCESS_HANDLE_BASE *psProcessHandleBase;
struct _SYNC_CONNECTION_DATA_ *psSyncConnectionData;
struct _PDUMP_CONNECTION_DATA_ *psPDumpConnectionData;
/* Holds the client flags supplied at connection time */
IMG_UINT32 ui32ClientFlags;
/*
* OS specific data can be stored via this handle.
* See osconnection_server.h for a generic mechanism
* for initialising this field.
*/
IMG_HANDLE hOsPrivateData;
#define PVRSRV_CONNECTION_PROCESS_NAME_LEN (16)
IMG_PID pid;
IMG_PID vpid;
IMG_UINT32 tid;
IMG_CHAR pszProcName[PVRSRV_CONNECTION_PROCESS_NAME_LEN];
IMG_HANDLE hProcessStats;
IMG_HANDLE hClientTLStream;
#if defined(SUPPORT_CUSTOM_OSID_EMISSION)
/*
* Connection-based values per application which can be modified by the
* AppHint settings 'OSid, OSidReg, bOSidAxiProtReg' for each application.
* These control where the connection's memory allocation is sourced from.
* ui32OSid, ui32OSidReg range from 0..(GPUVIRT_VALIDATION_NUM_OS - 1).
*/
IMG_UINT32 ui32OSid;
IMG_UINT32 ui32OSidReg;
IMG_BOOL bOSidAxiProtReg;
#endif /* defined(SUPPORT_CUSTOM_OSID_EMISSION) */
#if defined(SUPPORT_DMA_TRANSFER)
IMG_BOOL bAcceptDmaRequests;
ATOMIC_T ui32NumDmaTransfersInFlight;
IMG_HANDLE hDmaEventObject;
#endif
/* Structure which is hooked into the cleanup thread work list */
PVRSRV_CLEANUP_THREAD_WORK sCleanupThreadFn;
DLLIST_NODE sConnectionListNode;
/* List navigation for deferred freeing of connection data */
struct _CONNECTION_DATA_ **ppsThis;
struct _CONNECTION_DATA_ *psNext;
} CONNECTION_DATA;
#include "osconnection_server.h"
PVRSRV_ERROR PVRSRVCommonConnectionConnect(void **ppvPrivData, void *pvOSData);
void PVRSRVCommonConnectionDisconnect(void *pvPrivData);
/**************************************************************************/ /*!
@Function PVRSRVGetPurgeConnectionPid
@Description Returns PID associated with Connection currently being purged by
Cleanup Thread. If no Connection is purged 0 is returned.
@Return PID associated with currently purged connection or 0 if no
connection is being purged
*/ /***************************************************************************/
IMG_PID PVRSRVGetPurgeConnectionPid(void);
void PVRSRVConnectionDebugNotify(PVRSRV_DEVICE_NODE *psDevNode,
DUMPDEBUG_PRINTF_FUNC *pfnDumpDebugPrintf,
void *pvDumpDebugFile);
#ifdef INLINE_IS_PRAGMA
#pragma inline(PVRSRVConnectionPrivateData)
#endif
static INLINE
IMG_HANDLE PVRSRVConnectionPrivateData(CONNECTION_DATA *psConnection)
{
return (psConnection != NULL) ? psConnection->hOsPrivateData : NULL;
}
#endif /* !defined(CONNECTION_SERVER_H) */

View File

@@ -0,0 +1,76 @@
/*************************************************************************/ /*!
@Title RGX Core BVNC 36.52.104.182
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef RGXCORE_KM_36_52_104_182_H
#define RGXCORE_KM_36_52_104_182_H
/* Automatically generated file (14/08/2023 09:10:43): Do not edit manually */
/* CS: @5849605 */
/******************************************************************************
* BVNC = 36.52.104.182
*****************************************************************************/
#define RGX_BVNC_KM_B 36
#define RGX_BVNC_KM_V 52
#define RGX_BVNC_KM_N 104
#define RGX_BVNC_KM_C 182
/******************************************************************************
* Errata
*****************************************************************************/
#define FIX_HW_BRN_63553
#define FIX_HW_BRN_71242
#define FIX_HW_BRN_71317
/******************************************************************************
* Enhancements
*****************************************************************************/
#define HW_ERN_42290
#define HW_ERN_42606
#define HW_ERN_47025
#define HW_ERN_57596
#endif /* RGXCORE_KM_36_52_104_182_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,71 @@
/*************************************************************************/ /*!
@File
@Title Common debug definitions and functions.
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef DEBUG_COMMON_H
#define DEBUG_COMMON_H
#include "pvrsrv_error.h"
#include "device.h"
PVRSRV_ERROR DebugCommonInitDriver(void);
void DebugCommonDeInitDriver(void);
const IMG_CHAR *PVRSRVGetDebugDevStateString(PVRSRV_DEVICE_STATE eDevState);
const IMG_CHAR *PVRSRVGetDebugHealthStatusString(PVRSRV_DEVICE_HEALTH_STATUS eHealthStatus);
const IMG_CHAR *PVRSRVGetDebugHealthReasonString(PVRSRV_DEVICE_HEALTH_REASON eHealthReason);
PVRSRV_ERROR DebugCommonInitDevice(PVRSRV_DEVICE_NODE *psDeviceNode);
void DebugCommonDeInitDevice(PVRSRV_DEVICE_NODE *psDeviceNode);
typedef struct _IMG_FLAGS2DESC_
{
IMG_UINT32 uiFlag;
const IMG_CHAR *pszLabel;
} IMG_FLAGS2DESC;
void DebugCommonFlagStrings(IMG_CHAR *psDesc,
IMG_UINT32 ui32DescSize,
const IMG_FLAGS2DESC *psConvTable,
IMG_UINT32 ui32TableSize,
IMG_UINT32 ui32Flags);
#endif /* DEBUG_COMMON_H */

View File

@@ -0,0 +1,700 @@
/**************************************************************************/ /*!
@File
@Title Common Device header
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Device related function templates and defines
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /***************************************************************************/
#ifndef DEVICE_H
#define DEVICE_H
#include "devicemem_heapcfg.h"
#include "mmu_common.h"
#include "ra.h" /* RA_ARENA */
#include "pvrsrv_device.h"
#include "sync_checkpoint.h"
#include "srvkm.h"
#include "physheap.h"
#include "sync_internal.h"
#include "dllist.h"
#include "rgx_bvnc_defs_km.h"
#include "lock.h"
#include "power.h"
#if defined(SUPPORT_GPUVIRT_VALIDATION)
#include "virt_validation_defs.h"
#endif
typedef struct _PVRSRV_POWER_DEV_TAG_ *PPVRSRV_POWER_DEV;
struct SYNC_RECORD;
struct _CONNECTION_DATA_;
struct _DEVMEMINT_CTX_;
/*************************************************************************/ /*!
@Function AllocUFOBlockCallback
@Description Device specific callback for allocation of a UFO block
@Input psDeviceNode Pointer to device node to allocate
the UFO for.
@Input ui32RequestedSize Minimum size of allocation requested
@Output ppsMemDesc Pointer to pointer for the memdesc of
the allocation
@Output pui32SyncAddr FW Base address of the UFO block
@Output puiSyncPrimBlockSize Size of the UFO block
@Return PVRSRV_OK if allocation was successful
*/ /**************************************************************************/
typedef PVRSRV_ERROR (*AllocUFOBlockCallback)(struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
IMG_UINT32 ui32RequestedSize,
DEVMEM_MEMDESC **ppsMemDesc,
IMG_UINT32 *pui32SyncAddr,
IMG_UINT32 *puiSyncPrimBlockSize);
/*************************************************************************/ /*!
@Function FreeUFOBlockCallback
@Description Device specific callback for freeing of a UFO
@Input psDeviceNode Pointer to device node that the UFO block was
allocated from.
@Input psMemDesc Pointer to pointer for the memdesc of the UFO
block to free.
*/ /**************************************************************************/
typedef void (*FreeUFOBlockCallback)(struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
DEVMEM_MEMDESC *psMemDesc);
typedef struct _PVRSRV_DEVICE_IDENTIFIER_
{
/* Pdump memory and register bank names */
IMG_CHAR *pszPDumpDevName;
IMG_CHAR *pszPDumpRegName;
/* Under Linux, this is the minor number of RenderNode corresponding to this Device */
IMG_INT32 i32KernelDeviceID;
/* Services layer enumeration of the device used in pvrdebug */
IMG_UINT32 ui32InternalID;
} PVRSRV_DEVICE_IDENTIFIER;
typedef struct _DEVICE_MEMORY_INFO_
{
/* Heap count. Doesn't include additional heaps from PVRSRVCreateDeviceMemHeap */
IMG_UINT32 ui32HeapCount;
/* Blueprints for creating new device memory contexts */
IMG_UINT32 uiNumHeapConfigs;
DEVMEM_HEAP_CONFIG *psDeviceMemoryHeapConfigArray;
DEVMEM_HEAP_BLUEPRINT *psDeviceMemoryHeap;
} DEVICE_MEMORY_INFO;
#define MMU_BAD_PHYS_ADDR (0xbadbad00badULL)
typedef struct __DEFAULT_PAGE__
{
/*Page handle for the page allocated (UMA/LMA)*/
PG_HANDLE sPageHandle;
POS_LOCK psPgLock;
/*Default page size in terms of log2 */
IMG_UINT32 ui32Log2PgSize;
IMG_UINT64 ui64PgPhysAddr;
#if defined(PDUMP)
IMG_HANDLE hPdumpPg;
#endif
} PVRSRV_DEF_PAGE;
#define PVRSRV_DEVICE_STATE_LIST \
X(UNDEFINED) \
X(CREATING) \
X(CREATED) \
X(ACTIVE) \
X(FROZEN) \
X(DEINIT) \
X(DESTRUCTING) \
X(BAD) \
X(PCI_ERROR) \
X(LAST) \
typedef enum _PVRSRV_DEVICE_STATE_
{
#define X(_name) PVRSRV_DEVICE_STATE_ ## _name,
PVRSRV_DEVICE_STATE_LIST
#undef X
} PVRSRV_DEVICE_STATE;
#define PVRSRV_DEVICE_HEALTH_STATUS_LIST \
X(UNDEFINED) \
X(OK) \
X(NOT_RESPONDING) \
X(DEAD) \
X(FAULT) \
X(LAST) \
typedef enum _PVRSRV_DEVICE_HEALTH_STATUS_
{
#define X(_name) PVRSRV_DEVICE_HEALTH_STATUS_ ## _name,
PVRSRV_DEVICE_HEALTH_STATUS_LIST
#undef X
} PVRSRV_DEVICE_HEALTH_STATUS;
#define PVRSRV_DEVICE_HEALTH_REASON_LIST \
X(NONE) \
X(ASSERTED) \
X(POLL_FAILING) \
X(TIMEOUTS) \
X(QUEUE_CORRUPT) \
X(QUEUE_STALLED) \
X(IDLING) \
X(RESTARTING) \
X(MISSING_INTERRUPTS) \
X(PCI_ERROR) \
X(LAST) \
typedef enum _PVRSRV_DEVICE_HEALTH_REASON_
{
#define X(_name) PVRSRV_DEVICE_HEALTH_REASON_ ## _name,
PVRSRV_DEVICE_HEALTH_REASON_LIST
#undef X
} PVRSRV_DEVICE_HEALTH_REASON;
typedef enum _PVRSRV_DEVICE_DEBUG_DUMP_STATUS_
{
PVRSRV_DEVICE_DEBUG_DUMP_NONE = 0,
PVRSRV_DEVICE_DEBUG_DUMP_CAPTURE
} PVRSRV_DEVICE_DEBUG_DUMP_STATUS;
#ifndef DI_GROUP_DEFINED
#define DI_GROUP_DEFINED
typedef struct DI_GROUP DI_GROUP;
#endif
#ifndef DI_ENTRY_DEFINED
#define DI_ENTRY_DEFINED
typedef struct DI_ENTRY DI_ENTRY;
#endif
#if (RGX_NUM_DRIVERS_SUPPORTED > 1)
#ifndef DI_VZ_DATA_DEFINED
#define DI_VZ_DATA_DEFINED
typedef struct DI_VZ_DATA DI_VZ_DATA;
#endif
#endif
typedef struct _PVRSRV_DEVICE_DEBUG_INFO_
{
DI_GROUP *psGroup;
DI_ENTRY *psDumpDebugEntry;
#ifdef SUPPORT_RGX
DI_ENTRY *psUtilStatsEntry;
DI_ENTRY *psFWTraceEntry;
#ifdef SUPPORT_FIRMWARE_GCOV
DI_ENTRY *psFWGCOVEntry;
#endif
DI_ENTRY *psFWMappingsEntry;
#if defined(SUPPORT_RISCV_GDB)
DI_ENTRY *psRiscvDmiDIEntry;
IMG_UINT64 ui64RiscvDmi;
#endif
DI_ENTRY *psDevMemEntry;
#endif /* SUPPORT_RGX */
#ifdef SUPPORT_POWER_SAMPLING_VIA_DEBUGFS
DI_ENTRY *psPowerDataEntry;
#endif
#if defined(PVRSRV_ENABLE_PROCESS_STATS)
DI_ENTRY *psPowerTimingStatsEntry;
#endif
#if (RGX_NUM_DRIVERS_SUPPORTED > 1)
DI_GROUP *psVZGroup;
DI_GROUP *apsVZDriverGroups[RGX_NUM_DRIVERS_SUPPORTED];
DI_ENTRY *apsVZDriverPriorityDIEntries[RGX_NUM_DRIVERS_SUPPORTED];
DI_ENTRY *apsVZDriverTimeSliceDIEntries[RGX_NUM_DRIVERS_SUPPORTED];
DI_ENTRY *psVZDriverTimeSliceIntervalDIEntry;
DI_ENTRY *apsVZDriverIsolationGroupDIEntries[RGX_NUM_DRIVERS_SUPPORTED];
DI_VZ_DATA *apsVZDriverData[RGX_NUM_DRIVERS_SUPPORTED];
DI_ENTRY *psVZDriverConnectionCooldownPeriodDIEntry;
#endif
} PVRSRV_DEVICE_DEBUG_INFO;
#if defined(PVRSRV_DEBUG_LISR_EXECUTION)
#define RGX_LISR_INIT (0U)
#define RGX_LISR_DEVICE_NOT_POWERED (1U)
#define RGX_LISR_NOT_TRIGGERED_BY_HW (2U)
#define RGX_LISR_FW_IRQ_COUNTER_NOT_UPDATED (3U)
#define RGX_LISR_PROCESSED (4U)
typedef IMG_UINT32 LISR_STATUS;
typedef struct _LISR_EXECUTION_INFO_
{
/* status of last LISR invocation */
LISR_STATUS ui32Status;
/* snapshot from the last LISR invocation */
#if defined(RGX_FW_IRQ_OS_COUNTERS)
IMG_UINT32 aui32InterruptCountSnapshot[RGX_NUM_DRIVERS_SUPPORTED];
#else
IMG_UINT32 aui32InterruptCountSnapshot[RGXFW_THREAD_NUM];
#endif
/* time of the last LISR invocation */
IMG_UINT64 ui64Clockns;
} LISR_EXECUTION_INFO;
#if !defined(__CHECKER__)
#define UPDATE_LISR_DBG_STATUS(status) \
do { \
psDeviceNode->sLISRExecutionInfo.ui32Status = (status); \
if ((status > RGX_LISR_INIT) && (status < RGX_LISR_PROCESSED)) \
{ \
PVR_DPF((PVR_DBG_ERROR, "%s: IRQ %" IMG_UINT64_FMTSPEC " rejected: %s", __func__, psDeviceNode->ui64nLISR, #status)); \
} \
} while (0)
#define UPDATE_LISR_DBG_SNAPSHOT(idx, val) psDeviceNode->sLISRExecutionInfo.aui32InterruptCountSnapshot[idx] = (val)
#define UPDATE_LISR_DBG_TIMESTAMP() psDeviceNode->sLISRExecutionInfo.ui64Clockns = OSClockns64()
#define UPDATE_LISR_DBG_COUNTER() psDeviceNode->ui64nLISR++
#define UPDATE_MISR_DBG_COUNTER() psDeviceNode->ui64nMISR++
#else /*!defined(__CHECKER__) */
#define UPDATE_LISR_DBG_STATUS(status)
#define UPDATE_LISR_DBG_SNAPSHOT(idx, val)
#define UPDATE_LISR_DBG_TIMESTAMP()
#define UPDATE_LISR_DBG_COUNTER()
#define UPDATE_MISR_DBG_COUNTER()
#endif /* !defined(__CHECKER__) */
#else /* defined(PVRSRV_DEBUG_LISR_EXECUTION) */
#define UPDATE_LISR_DBG_STATUS(status)
#define UPDATE_LISR_DBG_SNAPSHOT(idx, val)
#define UPDATE_LISR_DBG_TIMESTAMP()
#define UPDATE_LISR_DBG_COUNTER()
#define UPDATE_MISR_DBG_COUNTER()
#endif /* defined(PVRSRV_DEBUG_LISR_EXECUTION) */
typedef struct _PVRSRV_DEVICE_NODE_
{
PVRSRV_DEVICE_IDENTIFIER sDevId;
PVRSRV_DEVICE_STATE eDevState; /* Set using PVRSRVDeviceSetState, not directly. */
PVRSRV_DEVICE_FABRIC_TYPE eDevFabricType;
ATOMIC_T eHealthStatus; /* Holds values from PVRSRV_DEVICE_HEALTH_STATUS */
ATOMIC_T eHealthReason; /* Holds values from PVRSRV_DEVICE_HEALTH_REASON */
ATOMIC_T eDebugDumpRequested; /* Holds values from PVRSRV_DEVICE_DEBUG_DUMP_STATUS */
IMG_HANDLE *hDebugTable;
/* device specific MMU attributes */
MMU_DEVICEATTRIBS *psMMUDevAttrs;
/* Device specific MMU firmware attributes, used only in some devices */
MMU_DEVICEATTRIBS *psFirmwareMMUDevAttrs;
/* Physical Heap where MMU PT pages are allocated from, normally the
* system's default physical heap but can be different for AutoVz driver. */
PHYS_HEAP *psMMUPhysHeap;
/* lock for power state transitions */
POS_LOCK hPowerLock;
IMG_PID uiPwrLockOwnerPID; /* Only valid between lock and corresponding unlock
operations of hPowerLock */
#if defined(DEBUG)
struct
{
const char *pszFile; /* Power lock acquired location (File) */
IMG_UINT32 ui32LineNum; /* Power lock acquired location (Line number) */
IMG_UINT64 ui64Timestamp; /* Power lock acquired timestamp */
} sPowerLockOwner;
#endif
#if defined(SUPPORT_PMR_DEFERRED_FREE) || defined(SUPPORT_MMU_DEFERRED_FREE)
IMG_UINT32 uiPowerOffCounter; /* Counts how many times the device has been powered
off. Incremented in PVRSRVSetDeviceCurrentPowerState().*/
IMG_UINT32 uiPowerOffCounterNext; /* Value of next update to uiPowerOffCounter. */
#endif
/* current system device power state */
PVRSRV_SYS_POWER_STATE eCurrentSysPowerState;
PPVRSRV_POWER_DEV psPowerDev;
/*
callbacks the device must support:
*/
PVRSRV_ERROR (*pfnInvalFBSCTable)(struct _PVRSRV_DEVICE_NODE_ *psDevNode,
MMU_CONTEXT *psMMUContext,
IMG_UINT64 ui64FBSCEntries);
PVRSRV_ERROR (*pfnValidateOrTweakPhysAddrs)(struct _PVRSRV_DEVICE_NODE_ *psDevNode,
MMU_DEVICEATTRIBS *psDevAttrs,
IMG_UINT64 *pui64Addr);
void (*pfnMMUCacheInvalidate)(struct _PVRSRV_DEVICE_NODE_ *psDevNode,
MMU_CONTEXT *psMMUContext,
MMU_LEVEL eLevel,
IMG_BOOL bUnmap);
PVRSRV_ERROR (*pfnMMUCacheInvalidateKick)(struct _PVRSRV_DEVICE_NODE_ *psDevNode,
IMG_UINT32 *pui32NextMMUInvalidateUpdate);
PVRSRV_ERROR (*pfnMMUCacheInvalidateKickAndWait)(struct _PVRSRV_DEVICE_NODE_ *psDevNode);
IMG_UINT32 (*pfnMMUCacheGetInvalidateCounter)(struct _PVRSRV_DEVICE_NODE_ *psDevNode);
/* Callback pfnMMUTopLevelPxWorkarounds may be NULL if not required */
void (*pfnMMUTopLevelPxWorkarounds)(struct _CONNECTION_DATA_ *psConnection,
struct _PVRSRV_DEVICE_NODE_ *psDevNode,
IMG_DEV_PHYADDR sPhysAddrL1Px,
void *pxL1PxCpuVAddr);
/* Callback pfnMMUTweakProtFlags may be NULL if not required */
void (*pfnMMUTweakProtFlags)(struct _PVRSRV_DEVICE_NODE_ *psDevNode,
MMU_DEVICEATTRIBS *psDevAttrs,
PVRSRV_MEMALLOCFLAGS_T uiMappingFlags,
MMU_PROTFLAGS_T *uiMMUProtFlags);
void (*pfnDumpDebugInfo)(struct _PVRSRV_DEVICE_NODE_ *psDevNode);
PVRSRV_ERROR (*pfnUpdateHealthStatus)(struct _PVRSRV_DEVICE_NODE_ *psDevNode,
IMG_BOOL bIsTimerPoll);
#if defined(SUPPORT_AUTOVZ)
void (*pfnUpdateAutoVzWatchdog)(struct _PVRSRV_DEVICE_NODE_ *psDevNode);
#endif
PVRSRV_ERROR (*pfnValidationGPUUnitsPowerChange)(struct _PVRSRV_DEVICE_NODE_ *psDevNode, IMG_UINT32 ui32NewState, IMG_BOOL bCallerHasPowerLock);
PVRSRV_ERROR (*pfnResetHWRLogs)(struct _PVRSRV_DEVICE_NODE_ *psDevNode);
PVRSRV_ERROR (*pfnVerifyBVNC)(struct _PVRSRV_DEVICE_NODE_ *psDevNode, IMG_UINT64 ui64GivenBVNC, IMG_UINT64 ui64CoreIdMask);
/* Method to drain device HWPerf packets from firmware buffer to host buffer */
PVRSRV_ERROR (*pfnServiceHWPerf)(struct _PVRSRV_DEVICE_NODE_ *psDevNode);
PVRSRV_ERROR (*pfnDeviceVersionString)(struct _PVRSRV_DEVICE_NODE_ *psDevNode, IMG_CHAR **ppszVersionString);
PVRSRV_ERROR (*pfnDeviceClockSpeed)(struct _PVRSRV_DEVICE_NODE_ *psDevNode, IMG_PUINT32 pui32RGXClockSpeed);
PVRSRV_ERROR (*pfnSoftReset)(struct _PVRSRV_DEVICE_NODE_ *psDevNode, IMG_UINT64 ui64ResetValue1, IMG_UINT64 ui64ResetValue2);
PVRSRV_ERROR (*pfnAlignmentCheck)(struct _PVRSRV_DEVICE_NODE_ *psDevNode, IMG_UINT32 ui32FWAlignChecksSize, IMG_UINT32 aui32FWAlignChecks[]);
IMG_BOOL (*pfnCheckDeviceFeature)(struct _PVRSRV_DEVICE_NODE_ *psDevNode, IMG_UINT16 ui16FeatureArrayIndex, IMG_UINT64 ui64FeatureMask);
IMG_INT32 (*pfnGetDeviceFeatureValue)(struct _PVRSRV_DEVICE_NODE_ *psDevNode, enum _RGX_FEATURE_WITH_VALUE_INDEX_ eFeatureIndex);
PVRSRV_ERROR (*pfnGetMultiCoreInfo)(struct _PVRSRV_DEVICE_NODE_ *psDevNode, IMG_UINT32 ui32CapsSize,
IMG_UINT32 *pui32NumCores, IMG_UINT64 *pui64Caps);
IMG_BOOL (*pfnHasFBCDCVersion31)(struct _PVRSRV_DEVICE_NODE_ *psDevNode);
IMG_UINT32 (*pfnGetTFBCLossyGroup)(struct _PVRSRV_DEVICE_NODE_ *psDevNode);
IMG_UINT32 (*pfnGetSLCSize)(struct _PVRSRV_DEVICE_NODE_ *psDevNode);
MMU_DEVICEATTRIBS* (*pfnGetMMUDeviceAttributes)(struct _PVRSRV_DEVICE_NODE_ *psDevNode, IMG_BOOL bKernelMemoryCtx);
PVRSRV_DEVICE_SNOOP_MODE (*pfnGetDeviceSnoopMode)(struct _PVRSRV_DEVICE_NODE_ *psDevNode);
PVRSRV_DEVICE_CONFIG *psDevConfig;
/* device post-finalise compatibility check */
PVRSRV_ERROR (*pfnInitDeviceCompatCheck) (struct _PVRSRV_DEVICE_NODE_*);
/* initialise device-specific physheaps */
PVRSRV_ERROR (*pfnPhysMemDeviceHeapsInit) (struct _PVRSRV_DEVICE_NODE_ *);
/* determining the appropriate LMA allocation policy */
PHYS_HEAP_POLICY (*pfnPhysHeapGetLMAPolicy) (PHYS_HEAP_USAGE_FLAGS, struct _PVRSRV_DEVICE_NODE_ *psDevNode);
/* initialise fw mmu, if FW not using GPU mmu, NULL otherwise. */
PVRSRV_ERROR (*pfnFwMMUInit) (struct _PVRSRV_DEVICE_NODE_ *);
/* Check device's FW Main physheap free memory */
PVRSRV_ERROR (*pfnCheckForSufficientFWPhysMem) (struct _PVRSRV_DEVICE_NODE_ *);
/* information about the device's address space and heaps */
DEVICE_MEMORY_INFO sDevMemoryInfo;
/* device's shared-virtual-memory heap max virtual address */
IMG_UINT64 ui64GeneralSVMHeapTopVA;
ATOMIC_T iNumClockSpeedChanges;
/* private device information */
void *pvDevice;
#if defined(SUPPORT_GPUVIRT_VALIDATION)
RA_ARENA *psOSSharedArena;
RA_ARENA *psOSidSubArena[GPUVIRT_VALIDATION_NUM_OS];
#endif
/* When virtualisation support is enabled the Firmware heaps of virtualised
* drivers can be entirely premapped into the Fw's VA space, during init
* or during runtime on explicit request from Guest drivers. */
PHYS_HEAP *apsFWPremapPhysHeap[RGX_NUM_DRIVERS_SUPPORTED];
/* Head of the physical heap list. Tracks PhysHeap objects created from
* the PHYS_HEAP_CONFIG definitions supplied by the system layer at
* device creation time. There could be 1 or more and varies from system
* to system.
*/
struct _PHYS_HEAP_ *psPhysHeapList;
POS_LOCK hPhysHeapLock;
/* The apsPhysHeap array is a mapping table to the system's, often fewer,
* physical memory heaps defined for this device. It contains
* PVRSRV_PHYS_HEAP_LAST entries, one for each possible physical
* heaps allowed in the design. Each PhysHeap in the design is acquired
* and stored in the mapping table during device create. Fall-back logic
* is employed to ensure a valid heap is always found from the set defined
* in the system layer for the device. Responsibility for this is shared
* between the common layer (PhysHeapInitDeviceHeaps) and sub-device
* layer (pfnPhysMemDeviceHeapsInit).
* It is used in the PhysMem module to create PMRs from a given PhysHeap
* of memory. See PhysHeapCreatePMR()
*/
PHYS_HEAP *apsPhysHeap[PVRSRV_PHYS_HEAP_LAST];
IMG_UINT32 ui32UserAllocHeapCount;
/* Flag indicating if the firmware has been initialised during the
* 1st boot of the Host driver according to the AutoVz life-cycle. */
IMG_BOOL bAutoVzFwIsUp;
#if defined(SUPPORT_AUTOVZ)
IMG_BOOL bAutoVzAllowGPUPowerdown;
#endif
/* Flags indicating VM state and if PVZ calls originating from it are valid */
IMG_UINT32 ui32VmState;
struct _PVRSRV_DEVICE_NODE_ *psNext;
struct _PVRSRV_DEVICE_NODE_ **ppsThis;
/* Functions for notification about memory contexts */
PVRSRV_ERROR (*pfnRegisterMemoryContext)(struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
MMU_CONTEXT *psMMUContext,
struct _DEVMEMINT_CTX_ *psDevMemCtx,
IMG_HANDLE *hPrivData);
void (*pfnUnregisterMemoryContext)(IMG_HANDLE hPrivData);
/* Callback for validating heap's protection flags. */
IMG_BOOL (*pfnValidateAddressPermissions)(struct _PVRSRV_DEVICE_NODE_ *psDevNode,
MMU_CONTEXT *psMMUContext,
IMG_DEV_VIRTADDR sVDevAddr,
PVRSRV_MEMALLOCFLAGS_T uiFlags);
/* Functions for validation flags for exportable PMRs */
IMG_BOOL (*pfnValidateExportableFlags)(PVRSRV_MEMALLOCFLAGS_T uiFlags);
/* Functions for allocation/freeing of UFOs */
AllocUFOBlockCallback pfnAllocUFOBlock; /*!< Callback for allocation of a block of UFO memory */
FreeUFOBlockCallback pfnFreeUFOBlock; /*!< Callback for freeing of a block of UFO memory */
IMG_HANDLE hSyncServerRecordNotify;
POS_LOCK hSyncServerRecordLock;
IMG_UINT32 ui32SyncServerRecordCount;
IMG_UINT32 ui32SyncServerRecordCountHighWatermark;
DLLIST_NODE sSyncServerRecordList;
struct SYNC_RECORD *apsSyncServerRecordsFreed[PVRSRV_FULL_SYNC_TRACKING_HISTORY_LEN];
IMG_UINT32 uiSyncServerRecordFreeIdx;
IMG_HANDLE hSyncCheckpointRecordNotify;
POS_LOCK hSyncCheckpointRecordLock;
IMG_UINT32 ui32SyncCheckpointRecordCount;
IMG_UINT32 ui32SyncCheckpointRecordCountHighWatermark;
DLLIST_NODE sSyncCheckpointRecordList;
struct SYNC_CHECKPOINT_RECORD *apsSyncCheckpointRecordsFreed[PVRSRV_FULL_SYNC_TRACKING_HISTORY_LEN];
IMG_UINT32 uiSyncCheckpointRecordFreeIdx;
IMG_HANDLE hSyncCheckpointNotify;
POS_SPINLOCK hSyncCheckpointListLock; /*!< Protects sSyncCheckpointSyncsList */
DLLIST_NODE sSyncCheckpointSyncsList;
PSYNC_CHECKPOINT_CONTEXT hSyncCheckpointContext;
PSYNC_PRIM_CONTEXT hSyncPrimContext;
/* With this sync-prim we make sure the MMU cache is flushed
* before we free the page table memory */
PVRSRV_CLIENT_SYNC_PRIM *psMMUCacheSyncPrim;
IMG_UINT32 ui32NextMMUInvalidateUpdate;
IMG_HANDLE hCmdCompNotify;
IMG_HANDLE hDbgReqNotify;
IMG_HANDLE hAppHintDbgReqNotify;
IMG_HANDLE hPhysHeapDbgReqNotify;
/* Device MMU common module can support one other larger page size
* (e.g. 16KB) in addition to the default OS page size (often 4KB).
* If supported, device code will store the size here as a log2 value
* during device creation/registration. A 0 value will imply it is
* not supported.
*/
IMG_UINT32 ui32Non4KPageSizeLog2;
PVRSRV_DEF_PAGE sScratchPage;
PVRSRV_DEF_PAGE sDevZeroPage;
/* Lock protects access to sMemoryContextPageFaultNotifyListHead and
* per memory context DEVMEMINT_CTX::sProcessNotifyListHead lists. */
POSWR_LOCK hPageFaultNotifyLock;
DLLIST_NODE sMemoryContextPageFaultNotifyListHead;
/* System DMA channels */
IMG_UINT32 ui32RefCountDMA;
IMG_HANDLE hDmaTxChan;
IMG_HANDLE hDmaRxChan;
POS_LOCK hDmaTxLock;
POS_LOCK hDmaRxLock;
#if defined(PDUMP)
/*
* FBC clear color register default value to use.
*/
IMG_UINT64 ui64FBCClearColour;
/* Device-level callback which is called when pdump.exe starts.
* Should be implemented in device-specific init code, e.g. rgxinit.c
*/
PVRSRV_ERROR (*pfnPDumpInitDevice)(struct _PVRSRV_DEVICE_NODE_ *psDeviceNode);
/* device-level callback to return pdump ID associated to a memory context */
IMG_UINT32 (*pfnMMUGetContextID)(IMG_HANDLE hDevMemContext);
IMG_UINT8 *pui8DeferredSyncCPSignal; /*! Deferred fence events buffer */
IMG_UINT16 ui16SyncCPReadIdx; /*! Read index in the above deferred fence events buffer */
IMG_UINT16 ui16SyncCPWriteIdx; /*! Write index in the above deferred fence events buffer */
POS_LOCK hSyncCheckpointSignalLock; /*! Guards data shared between an sleepable-contexts */
void *pvSyncCPMISR; /*! MISR to emit pending/deferred fence signals */
void *hTransition; /*!< SyncCheckpoint PdumpTransition Cookie */
DLLIST_NODE sSyncCheckpointContextListHead; /*!< List head for the sync chkpt contexts */
POS_LOCK hSyncCheckpointContextListLock; /*! lock for accessing sync chkpt contexts list */
#endif
/* Members for linking which connections are open on this device */
POS_LOCK hConnectionsLock; /*!< Lock protecting sConnections */
DLLIST_NODE sConnections; /*!< The list of currently active connection objects for this device node */
#if defined(PVRSRV_DEBUG_LISR_EXECUTION)
LISR_EXECUTION_INFO sLISRExecutionInfo; /*!< Information about the last execution of the LISR */
IMG_UINT64 ui64nLISR; /*!< Number of LISR calls seen */
IMG_UINT64 ui64nMISR; /*!< Number of MISR calls made */
#endif
PVRSRV_DEVICE_DEBUG_INFO sDebugInfo;
IMG_BOOL bEnablePFDebug; /*!< EnablePageFaultDebug AppHint setting for device */
IMG_BOOL bCleanupThreadDisabled; /*!< Set to disable further Cleanup queue requests for device */
DLLIST_NODE sCleanupThreadWorkList; /*!< List of work for the cleanup thread associated with the device */
ATOMIC_T i32NumCleanupItems; /*!< Number of cleanup thread work items. Includes items being freed. */
#if defined(SUPPORT_PMR_DEFERRED_FREE)
/* Data for the deferred freeing of a PMR physical pages for a given device */
DLLIST_NODE sPMRZombieList; /*!< List of PMRs to free */
POS_LOCK hPMRZombieListLock; /*!< List lock */
IMG_UINT32 uiPMRZombieCount; /*!< Number of elements in the list */
IMG_UINT32 uiPMRZombieCountInCleanup; /*!< Number of elements in cleanup items */
#endif /* defined(SUPPORT_PMR_DEFERRED_FREE) */
ATOMIC_T eFrozen; /*< Frozen / Unfrozen indicator */
IMG_HANDLE hDeviceThreadEvObj; /*< Event Object for Freeze indicator */
IMG_HANDLE hDeviceFreezeThaw; /*< Event handle for Freeze/Thaw */
POS_LOCK hFreezeThawLock; /*< Freeze/Thaw lock */
ATOMIC_T iFreezeCount; /*< Number of blocked on frozen tasks */
ATOMIC_T iTotalFreezes; /*< Total number of times device frozen */
ATOMIC_T iThreadsActive; /*< Number of threads active on this device */
IMG_UINT64 ui64LastDeviceOffTimestamp; /* Last device power off timestamp */
IMG_UINT64 ui64LastDeviceOffHostTimestampNs; /* Last device power off host timestamp */
IMG_UINT64 ui64LastSOCTimerOffValue; /* Last device power off SOC timer value */
#if defined(PVRSRV_ANDROID_TRACE_GPU_WORK_PERIOD)
IMG_BOOL bGPUWorkPeriodFTraceEnabled;
#endif
#if defined(ANDROID)
ATOMIC_T iFBCSurfaceCount; /*< Android FBC surface counter */
#endif
#if defined(PVRSRV_MAX_REAL_TIME_CONTEXTS) && (PVRSRV_MAX_REAL_TIME_CONTEXTS > 1)
IMG_UINT32 *pui32RTContextCount;
#endif
} PVRSRV_DEVICE_NODE;
/*
* Macros to be used instead of calling directly the pfns since these macros
* will expand the feature passed as argument into the bitmask/index to work
* with the macros defined in rgx_bvnc_defs_km.h
*/
#define PVRSRV_IS_FEATURE_SUPPORTED(psDevNode, Feature) \
psDevNode->pfnCheckDeviceFeature(psDevNode, RGX_FEATURE_##Feature##_ARRAY_INDEX, RGX_FEATURE_##Feature##_BIT_MASK)
#define PVRSRV_GET_DEVICE_FEATURE_VALUE(psDevNode, Feature) \
psDevNode->pfnGetDeviceFeatureValue(psDevNode, RGX_FEATURE_##Feature##_IDX)
PVRSRV_ERROR PVRSRVDeviceFinalise(PVRSRV_DEVICE_NODE *psDeviceNode,
IMG_BOOL bInitSuccessful);
PVRSRV_ERROR PVRSRVDevInitCompatCheck(PVRSRV_DEVICE_NODE *psDeviceNode);
PVRSRV_ERROR RGXClientConnectCompatCheck_ClientAgainstFW(PVRSRV_DEVICE_NODE * psDeviceNode, IMG_UINT32 ui32ClientBuildOptions);
void PVRSRVDeviceSetState(PVRSRV_DEVICE_NODE *psDeviceNode, PVRSRV_DEVICE_STATE eNewDevState);
#define PVRSRVIsStatusRecoverable(eStatus) \
(((eStatus == PVRSRV_DEVICE_HEALTH_STATUS_DEAD)) ? \
IMG_FALSE : IMG_TRUE)
/* Determines if a 32-bit `uiCurrent` counter advanced to or beyond
* `uiRequired` value. The function takes into consideration that the
* counter could have wrapped around. */
static INLINE IMG_BOOL PVRSRVHasCounter32Advanced(IMG_UINT32 uiCurrent,
IMG_UINT32 uiRequired)
{
return uiCurrent >= uiRequired ?
/* ... with the counter wrapped around ...
* There can't be ~4 billion transactions completed, so consider wrapped */
(((uiCurrent - uiRequired) > 0xF0000000UL) ? IMG_FALSE : IMG_TRUE) :
/* There can't be ~4 billion transactions pending, so consider wrapped */
(((uiRequired - uiCurrent) > 0xF0000000UL) ? IMG_TRUE : IMG_FALSE);
}
#endif /* DEVICE_H */
/******************************************************************************
End of file (device.h)
******************************************************************************/

View File

@@ -0,0 +1,130 @@
/*************************************************************************/ /*!
@File device_connection.h
@Title
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#if !defined(DEVICE_CONNECTION_H)
#define DEVICE_CONNECTION_H
#include "img_types.h"
#include "img_defs.h"
#if defined(__KERNEL__)
typedef struct _PVRSRV_DEVICE_NODE_ *SHARED_DEV_CONNECTION;
#else
#include "connection.h"
typedef const struct PVRSRV_DEV_CONNECTION_TAG *SHARED_DEV_CONNECTION;
#endif
/******************************************************************************
* Device capability flags and masks
*
* Following bitmask shows allocated ranges and values for our device
* capability settings:
*
* 31 27 23 19 15 11 7 3 0
* |...|...|...|...|...|...|...|...
* ** CACHE_COHERENT [0x1..0x2]
* x PVRSRV_CACHE_COHERENT_DEVICE_FLAG
* x. PVRSRV_CACHE_COHERENT_CPU_FLAG
* *... NONMAPPABLE_MEMORY [0x8]
* x... PVRSRV_NONMAPPABLE_MEMORY_PRESENT_FLAG
* *.... PDUMP_IS_RECORDING [0x10]
* x.... PVRSRV_PDUMP_IS_RECORDING
* ***........ DEVMEM_SVM_ALLOC [0x100..0x400]
* x........ PVRSRV_DEVMEM_SVM_ALLOC_UNSUPPORTED
* x......... PVRSRV_DEVMEM_SVM_ALLOC_SUPPORTED
* x.......... PVRSRV_DEVMEM_SVM_ALLOC_CANFAIL
* *........... FBCDC_V3_1 [0x800]
* x........... FBCDC_V3_1_USED
* *............ PVRSRV_SYSTEM_DMA
* x............ PVRSRV_SYSTEM_DMA_USED
* *............. TFBC_LOSSY_GROUP
* x............. TFBC_LOSSY_GROUP_1
* |...|...|...|...|...|...|...|...
*****************************************************************************/
/* Flag to be passed over the bridge during connection stating whether CPU cache coherent is available*/
#define PVRSRV_CACHE_COHERENT_SHIFT (0)
#define PVRSRV_CACHE_COHERENT_DEVICE_FLAG (1U << PVRSRV_CACHE_COHERENT_SHIFT)
#define PVRSRV_CACHE_COHERENT_CPU_FLAG (2U << PVRSRV_CACHE_COHERENT_SHIFT)
#define PVRSRV_CACHE_COHERENT_EMULATE_FLAG (4U << PVRSRV_CACHE_COHERENT_SHIFT)
#define PVRSRV_CACHE_COHERENT_MASK (7U << PVRSRV_CACHE_COHERENT_SHIFT)
/* Flag to be passed over the bridge during connection stating whether CPU non-mappable memory is present */
#define PVRSRV_NONMAPPABLE_MEMORY_PRESENT_SHIFT (7)
#define PVRSRV_NONMAPPABLE_MEMORY_PRESENT_FLAG (1U << PVRSRV_NONMAPPABLE_MEMORY_PRESENT_SHIFT)
/* Flag to be passed over the bridge to indicate PDump activity */
#define PVRSRV_PDUMP_IS_RECORDING_SHIFT (4)
#define PVRSRV_PDUMP_IS_RECORDING (1U << PVRSRV_PDUMP_IS_RECORDING_SHIFT)
/* Flag to be passed over the bridge during connection stating SVM allocation availability */
#define PVRSRV_DEVMEM_SVM_ALLOC_SHIFT (8)
#define PVRSRV_DEVMEM_SVM_ALLOC_UNSUPPORTED (1U << PVRSRV_DEVMEM_SVM_ALLOC_SHIFT)
#define PVRSRV_DEVMEM_SVM_ALLOC_SUPPORTED (2U << PVRSRV_DEVMEM_SVM_ALLOC_SHIFT)
#define PVRSRV_DEVMEM_SVM_ALLOC_CANFAIL (4U << PVRSRV_DEVMEM_SVM_ALLOC_SHIFT)
/* Flag to be passed over the bridge during connection stating whether GPU uses FBCDC v3.1 */
#define PVRSRV_FBCDC_V3_1_USED_SHIFT (11)
#define PVRSRV_FBCDC_V3_1_USED (1U << PVRSRV_FBCDC_V3_1_USED_SHIFT)
/* Flag to be passed over the bridge during connection stating whether System has
DMA transfer capability to and from device memory */
#define PVRSRV_SYSTEM_DMA_SHIFT (12)
#define PVRSRV_SYSTEM_DMA_USED (1U << PVRSRV_SYSTEM_DMA_SHIFT)
/* Flag to be passed over the bridge during connection stating whether GPU supports TFBC and is
configured to use lossy compression control group 1 (25% / 37.5% / 50%) */
#define PVRSRV_TFBC_LOSSY_GROUP_SHIFT (13)
#define PVRSRV_TFBC_LOSSY_GROUP_1 (1U << PVRSRV_TFBC_LOSSY_GROUP_SHIFT)
static INLINE IMG_HANDLE GetBridgeHandle(SHARED_DEV_CONNECTION hDevConnection)
{
#if defined(__KERNEL__)
return hDevConnection;
#else
return hDevConnection->hServices;
#endif
}
#endif /* !defined(DEVICE_CONNECTION_H) */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,694 @@
/*************************************************************************/ /*!
@File
@Title Device Memory Management core internal
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Services internal interface to core device memory management
functions that are shared between client and server code.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef SRVCLIENT_DEVICEMEM_H
#define SRVCLIENT_DEVICEMEM_H
/******************************************************************************
* *
* +------------+ +------------+ +--------------+ +--------------+ *
* | a sub- | | a sub- | | an | | allocation | *
* | allocation | | allocation | | allocation | | also mapped | *
* | | | | | in proc 1 | | into proc 2 | *
* +------------+ +------------+ +--------------+ +--------------+ *
* | | | | *
* +--------------+ +--------------+ +--------------+ *
* | page gran- | | page gran- | | page gran- | *
* | ular mapping | | ular mapping | | ular mapping | *
* +--------------+ +--------------+ +--------------+ *
* | | | *
* | | | *
* | | | *
* +--------------+ +--------------+ *
* | | | | *
* | A "P.M.R." | | A "P.M.R." | *
* | | | | *
* +--------------+ +--------------+ *
* *
******************************************************************************/
/*
All device memory allocations are ultimately a view upon (not
necessarily the whole of) a "PMR".
A PMR is a "Physical Memory Resource", which may be a
"pre-faulted" lump of physical memory, or it may be a
representation of some physical memory that will be instantiated
at some future time.
PMRs always represent multiple of some power-of-2 "contiguity"
promised by the PMR, which will allow them to be mapped in whole
pages into the device MMU. As memory allocations may be smaller
than a page, these mappings may be suballocated and thus shared
between multiple allocations in one process. A PMR may also be
mapped simultaneously into multiple device memory contexts
(cross-process scenario), however, for security reasons, it is not
legal to share a PMR "both ways" at once, that is, mapped into
multiple processes and divided up amongst several suballocations.
This PMR terminology is introduced here for background
information, but is generally of little concern to the caller of
this API. This API handles suballocations and mappings, and the
caller thus deals primarily with MEMORY DESCRIPTORS representing
an allocation or suballocation, HEAPS representing ranges of
virtual addresses in a CONTEXT.
*/
/*
|<---------------------------context------------------------------>|
|<-------heap------->| |<-------heap------->|<-------heap------->|
|<-alloc->| | |<-alloc->|<-alloc->|| |<-alloc->| |
*/
#include "img_types.h"
#include "img_defs.h"
#include "devicemem_typedefs.h"
#include "pdumpdefs.h"
#include "pvrsrv_error.h"
#include "pvrsrv_memallocflags.h"
#include "pdump.h"
#include "device_connection.h"
typedef IMG_UINT32 DEVMEM_HEAPCFGID;
#define DEVMEM_HEAPCFG_FORCLIENTS 0
#define DEVMEM_HEAPCFG_FORFW 1
/*
In order to call the server side functions, we need a bridge handle.
We abstract that here, as we may wish to change its form.
*/
typedef IMG_HANDLE DEVMEM_BRIDGE_HANDLE;
IMG_INTERNAL PVRSRV_ERROR
DevmemGetHeapInt(DEVMEM_HEAP *psHeap,
IMG_HANDLE *phDevmemHeap);
IMG_INTERNAL PVRSRV_ERROR
DevmemGetSize(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_SIZE_T* puiSize);
IMG_INTERNAL void
DevmemGetAnnotation(DEVMEM_MEMDESC *psMemDesc,
IMG_CHAR **pszAnnotation);
/*
* DevmemCreateContext()
*
* Create a device memory context
*
* This must be called before any heap is created in this context
*
* Caller to provide bridge handle which will be recorded internally and used
* for all future operations on items from this memory context. Caller also
* to provide devicenode handle, as this is used for MMU configuration and
* also to determine the heap configuration for the auto-instantiated heaps.
*
* Note that when compiled in services/server, the hBridge is not used and
* is thrown away by the "fake" direct bridge. (This may change. It is
* recommended that NULL be passed for the handle for now.)
*
* hDeviceNode and uiHeapBlueprintID shall together dictate which heap-config
* to use.
*
* This will cause the server side counterpart to be created also.
*
* If you call DevmemCreateContext() (and the call succeeds) you are promising
* that you will later call Devmem_ContextDestroy(), except for abnormal
* process termination in which case it is expected it will be destroyed as
* part of handle clean up.
*
* Caller to provide storage for the pointer to the newly created
* NEWDEVMEM_CONTEXT object.
*/
PVRSRV_ERROR
DevmemCreateContext(SHARED_DEV_CONNECTION hDevConnection,
DEVMEM_HEAPCFGID uiHeapBlueprintID,
DEVMEM_CONTEXT **ppsCtxPtr);
/*
* DevmemAcquireDevPrivData()
*
* Acquire the device private data for this memory context
*/
PVRSRV_ERROR
DevmemAcquireDevPrivData(DEVMEM_CONTEXT *psCtx,
IMG_HANDLE *hPrivData);
/*
* DevmemReleaseDevPrivData()
*
* Release the device private data for this memory context
*/
PVRSRV_ERROR
DevmemReleaseDevPrivData(DEVMEM_CONTEXT *psCtx);
/*
* DevmemDestroyContext()
*
* Undoes that done by DevmemCreateContext()
*/
PVRSRV_ERROR
DevmemDestroyContext(DEVMEM_CONTEXT *psCtx);
/*
* DevmemCreateHeap()
*
* Create a heap in the given context.
*
* N.B. Not intended to be called directly, though it can be.
* Normally, heaps are instantiated at context creation time according
* to the specified blueprint. See DevmemCreateContext() for details.
*
* This will cause MMU code to set up data structures for the heap,
* but may not cause page tables to be modified until allocations are
* made from the heap.
*
* uiReservedRegionLength Reserved address space for static VAs shared
* between clients and firmware
*
* The "Quantum" is both the device MMU page size to be configured for
* this heap, and the unit multiples of which "quantized" allocations
* are made (allocations smaller than this, known as "suballocations"
* will be made from a "sub alloc RA" and will "import" chunks
* according to this quantum)
*
* Where imported PMRs (or, for example, PMRs created by device class
* buffers) are mapped into this heap, it is important that the
* physical contiguity guarantee offered by the PMR is greater than or
* equal to the quantum size specified here, otherwise the attempt to
* map it will fail. "Normal" allocations via Devmem_Allocate
* shall automatically meet this requirement, as each "import" will
* trigger the creation of a PMR with the desired contiguity. The
* supported quantum sizes in that case shall be dictated by the OS
* specific implementation of PhysmemNewOSRamBackedPMR() (see)
*/
PVRSRV_ERROR
DevmemCreateHeap(DEVMEM_CONTEXT *psCtxPtr,
/* base and length of heap */
IMG_DEV_VIRTADDR sBaseAddress,
IMG_DEVMEM_SIZE_T uiLength,
IMG_DEVMEM_SIZE_T uiReservedRegionLength,
/* log2 of allocation quantum, i.e. "page" size.
All allocations (that go to server side) are
multiples of this. We use a client-side RA to
make sub-allocations from this */
IMG_UINT32 ui32Log2Quantum,
/* The minimum import alignment for this heap */
IMG_UINT32 ui32Log2ImportAlignment,
/* Name of heap for debug */
/* N.B. Okay to exist on caller's stack - this
func takes a copy if it needs it. */
const IMG_CHAR *pszName,
DEVMEM_HEAPCFGID uiHeapBlueprintID,
IMG_UINT32 uiHeapIndex,
DEVMEM_HEAP **ppsHeapPtr);
/*
* DevmemDestroyHeap()
*
* Reverses DevmemCreateHeap()
*
* N.B. All allocations must have been freed and all mappings must
* have been unmapped before invoking this call
*/
PVRSRV_ERROR
DevmemDestroyHeap(DEVMEM_HEAP *psHeap);
/*
* DevmemExportalignAdjustSizeAndAlign()
* Compute the Size and Align passed to avoid suballocations
* (used when allocation with PVRSRV_MEMALLOCFLAG_EXPORTALIGN).
*
* Returns PVRSRV_ERROR_INVALID_PARAMS if uiLog2Quantum has invalid value.
*/
IMG_INTERNAL PVRSRV_ERROR
DevmemExportalignAdjustSizeAndAlign(IMG_UINT32 uiLog2Quantum,
IMG_DEVMEM_SIZE_T *puiSize,
IMG_DEVMEM_ALIGN_T *puiAlign);
/*
* DevmemSubAllocate()
*
* Makes an allocation (possibly a "suballocation", as described
* below) of device virtual memory from this heap.
*
* The size and alignment of the allocation will be honoured by the RA
* that allocates the "suballocation". The resulting allocation will
* be mapped into GPU virtual memory and the physical memory to back
* it will exist, by the time this call successfully completes.
*
* The size must be a positive integer multiple of the alignment.
* (i.e. the alignment specifies the alignment of both the start and
* the end of the resulting allocation.)
*
* Allocations made via this API are routed through a "suballocation
* RA" which is responsible for ensuring that small allocations can be
* made without wasting physical memory in the server. Furthermore,
* such suballocations can be made entirely client side without
* needing to go to the server unless the allocation spills into a new
* page.
*
* Such suballocations cause many allocations to share the same "PMR".
* This happens only when the flags match exactly.
*
*/
PVRSRV_ERROR
DevmemSubAllocate(IMG_UINT8 uiPreAllocMultiplier,
DEVMEM_HEAP *psHeap,
IMG_DEVMEM_SIZE_T uiSize,
IMG_DEVMEM_ALIGN_T uiAlign,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
const IMG_CHAR *pszText,
DEVMEM_MEMDESC **ppsMemDescPtr);
#define DevmemAllocate(...) \
DevmemSubAllocate(DEVMEM_NO_PRE_ALLOCATE_MULTIPLIER, __VA_ARGS__)
PVRSRV_ERROR
DevmemAllocateExportable(SHARED_DEV_CONNECTION hDevConnection,
IMG_DEVMEM_SIZE_T uiSize,
IMG_DEVMEM_ALIGN_T uiAlign,
IMG_UINT32 uiLog2HeapPageSize,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
const IMG_CHAR *pszText,
DEVMEM_MEMDESC **ppsMemDescPtr);
PVRSRV_ERROR
DeviceMemChangeSparse(DEVMEM_MEMDESC *psMemDesc,
IMG_UINT32 ui32AllocPageCount,
IMG_UINT32 *paui32AllocPageIndices,
IMG_UINT32 ui32FreePageCount,
IMG_UINT32 *pauiFreePageIndices,
SPARSE_MEM_RESIZE_FLAGS uiFlags);
PVRSRV_ERROR
DevmemAllocateSparse(SHARED_DEV_CONNECTION hDevConnection,
IMG_DEVMEM_SIZE_T uiSize,
IMG_UINT32 ui32NumPhysChunks,
IMG_UINT32 ui32NumVirtChunks,
IMG_UINT32 *pui32MappingTable,
IMG_DEVMEM_ALIGN_T uiAlign,
IMG_UINT32 uiLog2HeapPageSize,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
const IMG_CHAR *pszText,
DEVMEM_MEMDESC **ppsMemDescPtr);
PVRSRV_ERROR
DevmemSubAllocateAndMap(IMG_UINT8 uiPreAllocMultiplier,
DEVMEM_HEAP *psHeap,
IMG_DEVMEM_SIZE_T uiSize,
IMG_DEVMEM_ALIGN_T uiAlign,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
const IMG_CHAR *pszText,
DEVMEM_MEMDESC **ppsMemDescPtr,
IMG_DEV_VIRTADDR *psDevVirtAddr);
#define DevmemAllocateAndMap(...) \
DevmemSubAllocateAndMap(DEVMEM_NO_PRE_ALLOCATE_MULTIPLIER, __VA_ARGS__)
/*
* DevmemFree()
*
* Reverses that done by DevmemSubAllocate() N.B. The underlying
* mapping and server side allocation _may_ not be torn down, for
* example, if the allocation has been exported, or if multiple
* allocations were suballocated from the same mapping, but this is
* properly refcounted, so the caller does not have to care.
*/
IMG_BOOL
DevmemFree(DEVMEM_MEMDESC *psMemDesc);
IMG_BOOL
DevmemReleaseDevAddrAndFree(DEVMEM_MEMDESC *psMemDesc);
/*
DevmemMapToDevice:
Map an allocation to the device it was allocated from.
This function _must_ be called before any call to
DevmemAcquireDevVirtAddr is made as it binds the allocation
to the heap.
DevmemReleaseDevVirtAddr is used to release the reference
to the device mapping this function created, but it doesn't
mean that the memory will actually be unmapped from the
device as other references to the mapping obtained via
DevmemAcquireDevVirtAddr could still be active.
*/
PVRSRV_ERROR DevmemMapToDevice(DEVMEM_MEMDESC *psMemDesc,
DEVMEM_HEAP *psHeap,
IMG_DEV_VIRTADDR *psDevVirtAddr);
/*
DevmemMapToDeviceAddress:
Same as DevmemMapToDevice but the caller chooses the address
to map to.
*/
IMG_INTERNAL PVRSRV_ERROR
DevmemMapToDeviceAddress(DEVMEM_MEMDESC *psMemDesc,
DEVMEM_HEAP *psHeap,
IMG_DEV_VIRTADDR sDevVirtAddr);
/*
DevmemGetDevVirtAddr
Obtain the MemDesc's device virtual address.
This function _must_ be called after DevmemMapToDevice(Address)
and is expected to be used be functions which didn't allocate
the MemDesc but need to know it's address.
It will PVR_ASSERT if no device mapping exists and 0 is returned.
*/
IMG_DEV_VIRTADDR
DevmemGetDevVirtAddr(DEVMEM_MEMDESC *psMemDesc);
/*
DevmemAcquireDevVirtAddr
Acquire the MemDesc's device virtual address.
This function _must_ be called after DevmemMapToDevice
and is expected to be used be functions which didn't allocate
the MemDesc but need to know it's address
*/
PVRSRV_ERROR DevmemAcquireDevVirtAddr(DEVMEM_MEMDESC *psMemDesc,
IMG_DEV_VIRTADDR *psDevVirtAddrRet);
/*
* DevmemReleaseDevVirtAddr()
*
* give up the licence to use the device virtual address that was
* acquired by "Acquire" or "MapToDevice"
*/
void
DevmemReleaseDevVirtAddr(DEVMEM_MEMDESC *psMemDesc);
/*
* DevmemAcquireCpuVirtAddr()
*
* Acquires a license to use the cpu virtual address of this mapping.
* Note that the memory may not have been mapped into cpu virtual
* memory prior to this call. On first "acquire" the memory will be
* mapped in (if it wasn't statically mapped in) and on last put it
* _may_ become unmapped. Later calling "Acquire" again, _may_ cause
* the memory to be mapped at a different address.
*/
PVRSRV_ERROR DevmemAcquireCpuVirtAddr(DEVMEM_MEMDESC *psMemDesc,
void **ppvCpuVirtAddr);
/*
* DevmemReacquireCpuVirtAddr()
*
* (Re)acquires license to use the cpu virtual address of this mapping
* if (and only if) there is already a pre-existing license to use the
* cpu virtual address for the mapping, returns NULL otherwise.
*/
void DevmemReacquireCpuVirtAddr(DEVMEM_MEMDESC *psMemDesc,
void **ppvCpuVirtAddr);
/*
* DevmemReleaseDevVirtAddr()
*
* give up the licence to use the cpu virtual address that was granted
* with the "Get" call.
*/
void
DevmemReleaseCpuVirtAddr(DEVMEM_MEMDESC *psMemDesc);
#if defined(SUPPORT_INSECURE_EXPORT)
/*
* DevmemExport()
*
* Given a memory allocation allocated with DevmemAllocateExportable()
* create a "cookie" that can be passed intact by the caller's own choice
* of secure IPC to another process and used as the argument to "map"
* to map this memory into a heap in the target processes. N.B. This can
* also be used to map into multiple heaps in one process, though that's not
* the intention.
*
* Note, the caller must later call Unexport before freeing the
* memory.
*/
PVRSRV_ERROR DevmemExport(DEVMEM_MEMDESC *psMemDesc,
DEVMEM_EXPORTCOOKIE *psExportCookie);
void DevmemUnexport(DEVMEM_MEMDESC *psMemDesc,
DEVMEM_EXPORTCOOKIE *psExportCookie);
PVRSRV_ERROR
DevmemImport(SHARED_DEV_CONNECTION hDevConnection,
DEVMEM_EXPORTCOOKIE *psCookie,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
DEVMEM_MEMDESC **ppsMemDescPtr);
#endif /* SUPPORT_INSECURE_EXPORT */
/*
* DevmemMakeLocalImportHandle()
*
* This is a "special case" function for making a server export cookie
* which went through the direct bridge into an export cookie that can
* be passed through the client bridge.
*/
PVRSRV_ERROR
DevmemMakeLocalImportHandle(SHARED_DEV_CONNECTION hDevConnection,
IMG_HANDLE hServerExport,
IMG_HANDLE *hClientExport);
/*
* DevmemUnmakeLocalImportHandle()
*
* Free any resource associated with the Make operation
*/
PVRSRV_ERROR
DevmemUnmakeLocalImportHandle(SHARED_DEV_CONNECTION hDevConnection,
IMG_HANDLE hClientExport);
/*
*
* The following set of functions is specific to the heap "blueprint"
* stuff, for automatic creation of heaps when a context is created
*
*/
/* Devmem_HeapConfigCount: returns the number of heap configs that
this device has. Note that there is no acquire/release semantics
required, as this data is guaranteed to be constant for the
lifetime of the device node */
PVRSRV_ERROR
DevmemHeapConfigCount(SHARED_DEV_CONNECTION hDevConnection,
IMG_UINT32 *puiNumHeapConfigsOut);
/* Devmem_HeapCount: returns the number of heaps that a given heap
config on this device has. Note that there is no acquire/release
semantics required, as this data is guaranteed to be constant for
the lifetime of the device node */
PVRSRV_ERROR
DevmemHeapCount(SHARED_DEV_CONNECTION hDevConnection,
IMG_UINT32 uiHeapConfigIndex,
IMG_UINT32 *puiNumHeapsOut);
/* Devmem_HeapConfigName: return the name of the given heap config.
The caller is to provide the storage for the returned string and
indicate the number of bytes (including null terminator) for such
string in the BufSz arg. Note that there is no acquire/release
semantics required, as this data is guaranteed to be constant for
the lifetime of the device node.
*/
PVRSRV_ERROR
DevmemHeapConfigName(SHARED_DEV_CONNECTION hsDevConnection,
IMG_UINT32 uiHeapConfigIndex,
IMG_CHAR *pszConfigNameOut,
IMG_UINT32 uiConfigNameBufSz);
/* Devmem_HeapDetails: fetches all the metadata that is recorded in
this heap "blueprint". Namely: heap name (caller to provide
storage, and indicate buffer size (including null terminator) in
BufSz arg), device virtual address and length, log2 of data page
size (will be one of 12, 14, 16, 18, 20, 21, at time of writing).
Note that there is no acquire/release semantics required, as this
data is guaranteed to be constant for the lifetime of the device
node. */
PVRSRV_ERROR
DevmemHeapDetails(SHARED_DEV_CONNECTION hDevConnection,
IMG_UINT32 uiHeapConfigIndex,
IMG_UINT32 uiHeapIndex,
IMG_CHAR *pszHeapNameOut,
IMG_UINT32 uiHeapNameBufSz,
IMG_DEV_VIRTADDR *psDevVAddrBaseOut,
IMG_DEVMEM_SIZE_T *puiHeapLengthOut,
IMG_DEVMEM_SIZE_T *puiReservedRegionLengthOut,
IMG_UINT32 *puiLog2DataPageSize,
IMG_UINT32 *puiLog2ImportAlignmentOut);
/*
* Devmem_FindHeapByName()
*
* returns the heap handle for the named _automagic_ heap in this
* context. "automagic" heaps are those that are born with the
* context from a blueprint
*/
PVRSRV_ERROR
DevmemFindHeapByName(const DEVMEM_CONTEXT *psCtx,
const IMG_CHAR *pszHeapName,
DEVMEM_HEAP **ppsHeapRet);
/*
* DevmemGetHeapBaseDevVAddr()
*
* returns the device virtual address of the base of the heap.
*/
PVRSRV_ERROR
DevmemGetHeapBaseDevVAddr(DEVMEM_HEAP *psHeap,
IMG_DEV_VIRTADDR *pDevVAddr);
/*
* DevmemGetHeapSize()
*
* returns the size of the heap.
*/
IMG_INTERNAL DEVMEM_SIZE_T
DevmemGetHeapSize(struct DEVMEM_HEAP_TAG *psHeap);
PVRSRV_ERROR
DevmemLocalGetImportHandle(DEVMEM_MEMDESC *psMemDesc,
IMG_HANDLE *phImport);
PVRSRV_ERROR
DevmemGetImportUID(DEVMEM_MEMDESC *psMemDesc,
IMG_UINT64 *pui64UID);
PVRSRV_ERROR
DevmemGetReservation(DEVMEM_MEMDESC *psMemDesc,
IMG_HANDLE *hReservation);
IMG_INTERNAL void
DevmemGetPMRData(DEVMEM_MEMDESC *psMemDesc,
IMG_HANDLE *hPMR,
IMG_DEVMEM_OFFSET_T *puiPMROffset);
IMG_INTERNAL void
DevmemGetFlags(DEVMEM_MEMDESC *psMemDesc,
PVRSRV_MEMALLOCFLAGS_T *puiFlags);
IMG_INTERNAL SHARED_DEV_CONNECTION
DevmemGetConnection(DEVMEM_MEMDESC *psMemDesc);
PVRSRV_ERROR
DevmemLocalImport(SHARED_DEV_CONNECTION hDevConnection,
IMG_HANDLE hExtHandle,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
DEVMEM_MEMDESC **ppsMemDescPtr,
IMG_DEVMEM_SIZE_T *puiSizePtr,
const IMG_CHAR *pszAnnotation);
IMG_INTERNAL PVRSRV_ERROR
DevmemIsDevVirtAddrValid(DEVMEM_CONTEXT *psContext,
IMG_DEV_VIRTADDR sDevVAddr);
IMG_INTERNAL PVRSRV_ERROR
DevmemGetFaultAddress(DEVMEM_CONTEXT *psContext,
IMG_DEV_VIRTADDR *psFaultAddress);
IMG_INTERNAL PVRSRV_ERROR
DevmemInvalidateFBSCTable(DEVMEM_CONTEXT *psContext,
IMG_UINT64 ui64FBSCEntries);
/* DevmemGetHeapLog2PageSize()
*
* Get the page size used for a certain heap.
*/
IMG_UINT32
DevmemGetHeapLog2PageSize(DEVMEM_HEAP *psHeap);
/* DevmemGetMemFlags()
*
* Get the memalloc flags for a certain memdesc.
*/
PVRSRV_MEMALLOCFLAGS_T
DevmemGetMemAllocFlags(DEVMEM_MEMDESC *psMemDesc);
/* DevmemGetHeapReservedSize()
*
* Get the reserved size used for a certain heap.
*/
IMG_DEVMEM_SIZE_T
DevmemGetHeapReservedSize(DEVMEM_HEAP *psHeap);
/*************************************************************************/ /*!
@Function RegisterDevMemPFNotify
@Description Registers that the application wants to be signaled when a page
fault occurs.
@Input psContext Memory context the process that would like to
be notified about.
@Input bRegister If true, register. If false, de-register.
@Return PVRSRV_ERROR: PVRSRV_OK on success. Otherwise, a PVRSRV_
error code
*/ /**************************************************************************/
IMG_INTERNAL PVRSRV_ERROR
RegisterDevmemPFNotify(DEVMEM_CONTEXT *psContext,
IMG_BOOL bRegister);
/*************************************************************************/ /*!
@Function DevmemHeapSetPremapStatus
@Description In some special cases like virtualisation, a device memory heap
must be entirely backed by physical memory and mapped into the
device's virtual address space. This is done at context creation.
When objects are allocated from such a heap, the mapping part
must be skipped. The 'bPremapped' flag dictates if allocations
are to be mapped or not.
@Input psHeap Device memory heap to be updated
@Input IsPremapped The premapping status to be set
*/ /**************************************************************************/
IMG_INTERNAL void
DevmemHeapSetPremapStatus(DEVMEM_HEAP *psHeap, IMG_BOOL IsPremapped);
#endif /* #ifndef SRVCLIENT_DEVICEMEM_H */

View File

@@ -0,0 +1,225 @@
/*************************************************************************/ /*!
@File devicemem_heapcfg.c
@Title Device Heap Configuration Helper Functions
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Device memory management
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /***************************************************************************/
/* our exported API */
#include "devicemem_heapcfg.h"
#include "devicemem_utils.h"
#include "device.h"
#include "img_types.h"
#include "img_defs.h"
#include "pvr_debug.h"
#include "pvrsrv_error.h"
#include "osfunc.h"
#include "connection_server.h"
static INLINE void _CheckBlueprintHeapAlignment(DEVMEM_HEAP_BLUEPRINT *psHeapBlueprint)
{
IMG_UINT32 ui32OSPageSize = OSGetPageSize();
/* Any heap length should at least match OS page size at the minimum or
* a multiple of OS page size */
if ((psHeapBlueprint->uiHeapLength < DEVMEM_HEAP_MINIMUM_SIZE) ||
(psHeapBlueprint->uiHeapLength & (ui32OSPageSize - 1)))
{
PVR_DPF((PVR_DBG_ERROR,
"%s: Invalid Heap \"%s\" Size: "
"%"IMG_UINT64_FMTSPEC
"("IMG_DEVMEM_SIZE_FMTSPEC")",
__func__,
psHeapBlueprint->pszName,
psHeapBlueprint->uiHeapLength,
psHeapBlueprint->uiHeapLength));
PVR_DPF((PVR_DBG_ERROR,
"Heap Size should always be at least the DevMem minimum size and a "
"multiple of OS Page Size:%u(0x%x)",
ui32OSPageSize, ui32OSPageSize));
PVR_ASSERT(psHeapBlueprint->uiHeapLength >= ui32OSPageSize);
}
PVR_ASSERT(psHeapBlueprint->uiReservedRegionLength % DEVMEM_HEAP_RESERVED_SIZE_GRANULARITY == 0);
}
void HeapCfgBlueprintInit(const IMG_CHAR *pszName,
IMG_UINT64 ui64HeapBaseAddr,
IMG_DEVMEM_SIZE_T uiHeapLength,
IMG_DEVMEM_SIZE_T uiReservedRegionLength,
IMG_UINT32 ui32Log2DataPageSize,
IMG_UINT32 uiLog2ImportAlignment,
PFN_HEAP_INIT pfnInit,
PFN_HEAP_DEINIT pfnDeInit,
DEVMEM_HEAP_BLUEPRINT *psHeapBlueprint)
{
psHeapBlueprint->pszName = pszName;
psHeapBlueprint->sHeapBaseAddr.uiAddr = ui64HeapBaseAddr;
psHeapBlueprint->uiHeapLength = uiHeapLength;
psHeapBlueprint->uiReservedRegionLength = uiReservedRegionLength;
psHeapBlueprint->uiLog2DataPageSize = ui32Log2DataPageSize;
psHeapBlueprint->uiLog2ImportAlignment = uiLog2ImportAlignment;
psHeapBlueprint->pfnInit = pfnInit;
psHeapBlueprint->pfnDeInit = pfnDeInit;
_CheckBlueprintHeapAlignment(psHeapBlueprint);
}
PVRSRV_ERROR
HeapCfgHeapConfigCount(CONNECTION_DATA * psConnection,
const PVRSRV_DEVICE_NODE *psDeviceNode,
IMG_UINT32 *puiNumHeapConfigsOut)
{
PVR_UNREFERENCED_PARAMETER(psConnection);
*puiNumHeapConfigsOut = psDeviceNode->sDevMemoryInfo.uiNumHeapConfigs;
return PVRSRV_OK;
}
PVRSRV_ERROR
HeapCfgHeapCount(CONNECTION_DATA * psConnection,
const PVRSRV_DEVICE_NODE *psDeviceNode,
IMG_UINT32 uiHeapConfigIndex,
IMG_UINT32 *puiNumHeapsOut)
{
PVR_UNREFERENCED_PARAMETER(psConnection);
if (uiHeapConfigIndex >= psDeviceNode->sDevMemoryInfo.uiNumHeapConfigs)
{
return PVRSRV_ERROR_DEVICEMEM_INVALID_HEAP_CONFIG_INDEX;
}
*puiNumHeapsOut = psDeviceNode->sDevMemoryInfo.psDeviceMemoryHeapConfigArray[uiHeapConfigIndex].uiNumHeaps;
return PVRSRV_OK;
}
PVRSRV_ERROR
HeapCfgHeapConfigName(CONNECTION_DATA * psConnection,
const PVRSRV_DEVICE_NODE *psDeviceNode,
IMG_UINT32 uiHeapConfigIndex,
IMG_UINT32 uiHeapConfigNameBufSz,
IMG_CHAR *pszHeapConfigNameOut)
{
PVR_UNREFERENCED_PARAMETER(psConnection);
if (uiHeapConfigIndex >= psDeviceNode->sDevMemoryInfo.uiNumHeapConfigs)
{
return PVRSRV_ERROR_DEVICEMEM_INVALID_HEAP_CONFIG_INDEX;
}
OSSNPrintf(pszHeapConfigNameOut, uiHeapConfigNameBufSz, "%s", psDeviceNode->sDevMemoryInfo.psDeviceMemoryHeapConfigArray[uiHeapConfigIndex].pszName);
return PVRSRV_OK;
}
PVRSRV_ERROR
HeapCfgGetCallbacks(const PVRSRV_DEVICE_NODE *psDeviceNode,
IMG_UINT32 uiHeapConfigIndex,
IMG_UINT32 uiHeapIndex,
PFN_HEAP_INIT *ppfnInit,
PFN_HEAP_DEINIT *ppfnDeinit)
{
DEVMEM_HEAP_BLUEPRINT *psHeapBlueprint;
PVR_LOG_RETURN_IF_INVALID_PARAM(psDeviceNode, "psDeviceNode");
PVR_LOG_RETURN_IF_INVALID_PARAM(ppfnInit, "ppfnInit");
PVR_LOG_RETURN_IF_INVALID_PARAM(ppfnDeinit, "ppfnDeinit");
if (uiHeapConfigIndex >= psDeviceNode->sDevMemoryInfo.uiNumHeapConfigs)
{
return PVRSRV_ERROR_DEVICEMEM_INVALID_HEAP_CONFIG_INDEX;
}
if (uiHeapIndex >= psDeviceNode->sDevMemoryInfo.psDeviceMemoryHeapConfigArray[uiHeapConfigIndex].uiNumHeaps)
{
return PVRSRV_ERROR_DEVICEMEM_INVALID_HEAP_INDEX;
}
psHeapBlueprint = &psDeviceNode->sDevMemoryInfo.psDeviceMemoryHeapConfigArray[uiHeapConfigIndex].psHeapBlueprintArray[uiHeapIndex];
*ppfnInit = psHeapBlueprint->pfnInit;
*ppfnDeinit = psHeapBlueprint->pfnDeInit;
return PVRSRV_OK;
}
PVRSRV_ERROR
HeapCfgHeapDetails(CONNECTION_DATA * psConnection,
const PVRSRV_DEVICE_NODE *psDeviceNode,
IMG_UINT32 uiHeapConfigIndex,
IMG_UINT32 uiHeapIndex,
IMG_UINT32 uiHeapNameBufSz,
IMG_CHAR *pszHeapNameOut,
IMG_DEV_VIRTADDR *psDevVAddrBaseOut,
IMG_DEVMEM_SIZE_T *puiHeapLengthOut,
IMG_DEVMEM_SIZE_T *puiReservedRegionLengthOut,
IMG_UINT32 *puiLog2DataPageSizeOut,
IMG_UINT32 *puiLog2ImportAlignmentOut)
{
DEVMEM_HEAP_BLUEPRINT *psHeapBlueprint;
PVR_UNREFERENCED_PARAMETER(psConnection);
if (uiHeapConfigIndex >= psDeviceNode->sDevMemoryInfo.uiNumHeapConfigs)
{
return PVRSRV_ERROR_DEVICEMEM_INVALID_HEAP_CONFIG_INDEX;
}
if (uiHeapIndex >= psDeviceNode->sDevMemoryInfo.psDeviceMemoryHeapConfigArray[uiHeapConfigIndex].uiNumHeaps)
{
return PVRSRV_ERROR_DEVICEMEM_INVALID_HEAP_INDEX;
}
psHeapBlueprint = &psDeviceNode->sDevMemoryInfo.psDeviceMemoryHeapConfigArray[uiHeapConfigIndex].psHeapBlueprintArray[uiHeapIndex];
OSSNPrintf(pszHeapNameOut, uiHeapNameBufSz, "%s", psHeapBlueprint->pszName);
*psDevVAddrBaseOut = psHeapBlueprint->sHeapBaseAddr;
*puiHeapLengthOut = psHeapBlueprint->uiHeapLength;
*puiReservedRegionLengthOut = psHeapBlueprint->uiReservedRegionLength;
*puiLog2DataPageSizeOut = psHeapBlueprint->uiLog2DataPageSize;
*puiLog2ImportAlignmentOut = psHeapBlueprint->uiLog2ImportAlignment;
return PVRSRV_OK;
}

View File

@@ -0,0 +1,213 @@
/**************************************************************************/ /*!
@File
@Title Device Heap Configuration Helper Functions
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Device memory management
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /***************************************************************************/
#ifndef DEVICEMEMHEAPCFG_H
#define DEVICEMEMHEAPCFG_H
#include <powervr/mem_types.h>
#include "img_types.h"
#include "pvrsrv_error.h"
struct _PVRSRV_DEVICE_NODE_;
struct _CONNECTION_DATA_;
struct _DEVMEMINT_HEAP_;
/*************************************************************************/ /*!
@Function Callback function PFN_HEAP_INIT
@Description Device heap initialisation function. Called in server devmem
heap create if the callback pointer in RGX_HEAP_INFO is
not NULL.
@Input psDeviceNode The device node.
@Input psDevmemHeap Server internal devmem heap.
@Output phPrivData Private data handle. Allocated resources
can be freed in PFN_HEAP_DEINIT.
@Return PVRSRV_ERROR PVRSRV_OK or error code
*/ /**************************************************************************/
typedef PVRSRV_ERROR (*PFN_HEAP_INIT)(struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
struct _DEVMEMINT_HEAP_ *psDevmemHeap,
IMG_HANDLE *phPrivData);
/*************************************************************************/ /*!
@Function Callback function PFN_HEAP_DEINIT
@Description Device heap deinit function. Called in server devmem
heap create if the callback pointer in RGX_HEAP_INFO is
not NULL.
@Input hPrivData Private data handle. To free any resources.
*/ /**************************************************************************/
typedef void (*PFN_HEAP_DEINIT)(IMG_HANDLE hPrivData);
/*
A "heap config" is a blueprint to be used for initial setting up of heaps
when a device memory context is created.
We define a data structure to define this, but it's really down to the
caller to populate it. This is all expected to be in-kernel. We provide an
API that client code can use to enquire about the blueprint, such that it may
do the heap set-up during the context creation call on behalf of the user.
*/
/* Blueprint for a single heap */
typedef struct _DEVMEM_HEAP_BLUEPRINT_
{
/* Name of this heap - for debug purposes, and perhaps for lookup
by name */
const IMG_CHAR *pszName;
/* Virtual address of the beginning of the heap. This _must_ be a
multiple of the data page size for the heap. It is
_recommended_ that it be coarser than that - especially, it
should begin on a boundary appropriate to the MMU for the
device. For Rogue, this is a Page Directory boundary, or 1GB
(virtual address a multiple of 0x0040000000). */
IMG_DEV_VIRTADDR sHeapBaseAddr;
/* Length of the heap. Given that the END address of the heap has
a similar restriction to that of the _beginning_ of the heap.
That is the heap length _must_ be a whole number of data pages.
Again, the recommendation is that it ends on a 1GB boundary.
Again, this is not essential, but we do know that (at the time
of writing) the current implementation of mmu_common.c is such
that no two heaps may share a page directory, thus the
remaining virtual space would be wasted if the length were not
a multiple of 1GB */
IMG_DEVMEM_SIZE_T uiHeapLength;
/* VA space starting sHeapBaseAddr to uiReservedRegionLength-1 are reserved
for statically defined addresses (shared/known between clients and FW).
Services never maps allocations into this reserved address space _unless_
explicitly requested via PVRSRVMapToDeviceAddress by passing sDevVirtAddr
which falls within this reserved range. Since this range is completely for
clients to manage (where allocations are page granular), it _must_ again be
a whole number of data pages. Additionally, another constraint enforces this
to be a multiple of DEVMEM_HEAP_RESERVED_SIZE_GRANULARITY (which evaluates to
max page size supported) to support varied pages sizes */
IMG_DEVMEM_SIZE_T uiReservedRegionLength;
/* Data page size. This is the page size that is going to get
programmed into the MMU, so it needs to be a valid one for the
device. Importantly, the start address and length _must_ be
multiples of this page size. Note that the page size is
specified as the log 2 relative to 1 byte (e.g. 12 indicates
4kB) */
IMG_UINT32 uiLog2DataPageSize;
/* Import alignment. Force imports to this heap to be
aligned to at least this value */
IMG_UINT32 uiLog2ImportAlignment;
/* Callback function for device specific heap init. */
PFN_HEAP_INIT pfnInit;
/* Callback function for device specific heap deinit. */
PFN_HEAP_DEINIT pfnDeInit;
} DEVMEM_HEAP_BLUEPRINT;
void HeapCfgBlueprintInit(const IMG_CHAR *pszName,
IMG_UINT64 ui64HeapBaseAddr,
IMG_DEVMEM_SIZE_T uiHeapLength,
IMG_DEVMEM_SIZE_T uiReservedRegionLength,
IMG_UINT32 ui32Log2DataPageSize,
IMG_UINT32 uiLog2ImportAlignment,
PFN_HEAP_INIT pfnInit,
PFN_HEAP_DEINIT pfnDeInit,
DEVMEM_HEAP_BLUEPRINT *psHeapBlueprint);
/* Entire named heap config */
typedef struct _DEVMEM_HEAP_CONFIG_
{
/* Name of this heap config - for debug and maybe lookup */
const IMG_CHAR *pszName;
/* Number of heaps in this config */
IMG_UINT32 uiNumHeaps;
/* Array of individual heap blueprints as defined above */
DEVMEM_HEAP_BLUEPRINT *psHeapBlueprintArray;
} DEVMEM_HEAP_CONFIG;
PVRSRV_ERROR
HeapCfgHeapConfigCount(struct _CONNECTION_DATA_ *psConnection,
const struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
IMG_UINT32 *puiNumHeapConfigsOut
);
PVRSRV_ERROR
HeapCfgHeapCount(struct _CONNECTION_DATA_ *psConnection,
const struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
IMG_UINT32 uiHeapConfigIndex,
IMG_UINT32 *puiNumHeapsOut
);
PVRSRV_ERROR
HeapCfgHeapConfigName(struct _CONNECTION_DATA_ *psConnection,
const struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
IMG_UINT32 uiHeapConfigIndex,
IMG_UINT32 uiHeapConfigNameBufSz,
IMG_CHAR *pszHeapConfigNameOut
);
PVRSRV_ERROR
HeapCfgHeapDetails(struct _CONNECTION_DATA_ *psConnection,
const struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
IMG_UINT32 uiHeapConfigIndex,
IMG_UINT32 uiHeapIndex,
IMG_UINT32 uiHeapNameBufSz,
IMG_CHAR *pszHeapNameOut,
IMG_DEV_VIRTADDR *psDevVAddrBaseOut,
IMG_DEVMEM_SIZE_T *puiHeapLengthOut,
IMG_DEVMEM_SIZE_T *puiReservedRegionLengthOut,
IMG_UINT32 *puiLog2DataPageSizeOut,
IMG_UINT32 *puiLog2ImportAlignmentOut
);
PVRSRV_ERROR
HeapCfgGetCallbacks(const struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
IMG_UINT32 uiHeapConfigIndex,
IMG_UINT32 uiHeapIndex,
PFN_HEAP_INIT *ppfnInit,
PFN_HEAP_DEINIT *ppfnDeinit);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,167 @@
/*************************************************************************/ /*!
@File devicemem_history_server.h
@Title Resource Information abstraction
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Devicemem History functions
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef DEVICEMEM_HISTORY_SERVER_H
#define DEVICEMEM_HISTORY_SERVER_H
#include "img_defs.h"
#include "pvrsrv_error.h"
#include "rgxmem.h"
#include "devicemem_utils.h"
#include "connection_server.h"
PVRSRV_ERROR DevicememHistoryInitKM(void);
void DevicememHistoryDeInitKM(void);
PVRSRV_ERROR DevicememHistoryDeviceInit(PVRSRV_DEVICE_NODE *psDevNode);
PVRSRV_ERROR DevicememHistoryDeviceCreate(PVRSRV_DEVICE_NODE *psDevNode);
void DevicememHistoryDeviceDestroy(PVRSRV_DEVICE_NODE *psDevNode);
PVRSRV_ERROR DevicememHistoryMapKM(PMR *psPMR,
IMG_UINT32 ui32Offset,
IMG_DEV_VIRTADDR sDevVAddr,
IMG_DEVMEM_SIZE_T uiSize,
const char szName[DEVMEM_ANNOTATION_MAX_LEN],
IMG_UINT32 ui32PageSize,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 *pui32AllocationIndexOut);
PVRSRV_ERROR DevicememHistoryUnmapKM(PMR *psPMR,
IMG_UINT32 ui32Offset,
IMG_DEV_VIRTADDR sDevVAddr,
IMG_DEVMEM_SIZE_T uiSize,
const char szName[DEVMEM_ANNOTATION_MAX_LEN],
IMG_UINT32 ui32PageSize,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 *pui32AllocationIndexOut);
PVRSRV_ERROR DevicememHistoryMapVRangeKM(CONNECTION_DATA *psConnection,
PVRSRV_DEVICE_NODE *psDeviceNode,
IMG_DEV_VIRTADDR sBaseDevVAddr,
IMG_UINT32 ui32StartPage,
IMG_UINT32 ui32NumPages,
IMG_DEVMEM_SIZE_T uiAllocSize,
const IMG_CHAR szName[DEVMEM_ANNOTATION_MAX_LEN],
IMG_UINT32 ui32Log2PageSize,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 *ui32AllocationIndexOut);
PVRSRV_ERROR DevicememHistoryUnmapVRangeKM(CONNECTION_DATA *psConnection,
PVRSRV_DEVICE_NODE *psDeviceNode,
IMG_DEV_VIRTADDR sBaseDevVAddr,
IMG_UINT32 ui32StartPage,
IMG_UINT32 ui32NumPages,
IMG_DEVMEM_SIZE_T uiAllocSize,
const IMG_CHAR szName[DEVMEM_ANNOTATION_MAX_LEN],
IMG_UINT32 ui32Log2PageSize,
IMG_UINT32 ui32AllocationIndex,
IMG_UINT32 *ui32AllocationIndexOut);
PVRSRV_ERROR DevicememHistorySparseChangeKM(PMR *psPMR,
IMG_UINT32 ui32Offset,
IMG_DEV_VIRTADDR sDevVAddr,
IMG_DEVMEM_SIZE_T uiSize,
const char szName[DEVMEM_ANNOTATION_MAX_LEN],
IMG_UINT32 ui32PageSize,
IMG_UINT32 ui32AllocPageCount,
IMG_UINT32 *paui32AllocPageIndices,
IMG_UINT32 ui32FreePageCount,
IMG_UINT32 *pauiFreePageIndices,
IMG_UINT32 AllocationIndex,
IMG_UINT32 *pui32AllocationIndexOut);
/* used when the PID does not matter */
#define DEVICEMEM_HISTORY_PID_ANY 0xFFFFFFFE
typedef struct _DEVICEMEM_HISTORY_QUERY_IN_
{
IMG_PID uiPID;
IMG_DEV_VIRTADDR sDevVAddr;
PVRSRV_DEVICE_NODE *psDevNode;
} DEVICEMEM_HISTORY_QUERY_IN;
/* Store up to 4 results for a lookup. In the case of the faulting page being
* re-mapped between the page fault occurring on HW and the page fault analysis
* being done, the second result entry will show the allocation being unmapped.
* A further 2 entries are added to cater for multiple buffers in the same page.
*/
#define DEVICEMEM_HISTORY_QUERY_OUT_MAX_RESULTS 4
typedef struct _DEVICEMEM_HISTORY_QUERY_OUT_RESULT_
{
IMG_CHAR szString[DEVMEM_ANNOTATION_MAX_LEN];
IMG_DEV_VIRTADDR sBaseDevVAddr;
IMG_DEVMEM_SIZE_T uiSize;
IMG_BOOL bMap;
IMG_BOOL bRange;
IMG_BOOL bAll;
IMG_UINT64 ui64When;
IMG_UINT64 ui64Age;
/* info for sparse map/unmap operations (i.e. bRange=IMG_TRUE) */
IMG_UINT32 ui32StartPage;
IMG_UINT32 ui32PageCount;
IMG_DEV_VIRTADDR sMapStartAddr;
IMG_DEV_VIRTADDR sMapEndAddr;
RGXMEM_PROCESS_INFO sProcessInfo;
} DEVICEMEM_HISTORY_QUERY_OUT_RESULT;
typedef struct _DEVICEMEM_HISTORY_QUERY_OUT_
{
IMG_UINT32 ui32NumResults;
IMG_UINT64 ui64SearchCount;
/* result 0 is the newest */
DEVICEMEM_HISTORY_QUERY_OUT_RESULT sResults[DEVICEMEM_HISTORY_QUERY_OUT_MAX_RESULTS];
} DEVICEMEM_HISTORY_QUERY_OUT;
void DevicememHistoryDumpRecordStats(PVRSRV_DEVICE_NODE *psDevNode,
DUMPDEBUG_PRINTF_FUNC *pfnDumpDebugPrintf,
void *pvDumpDebugFile);
IMG_BOOL
DevicememHistoryQuery(DEVICEMEM_HISTORY_QUERY_IN *psQueryIn,
DEVICEMEM_HISTORY_QUERY_OUT *psQueryOut,
IMG_UINT32 ui32PageSizeBytes,
IMG_BOOL bMatchAnyAllocInPage);
#endif

View File

@@ -0,0 +1,363 @@
/*************************************************************************/ /*!
@File
@Title Device Memory Management PDump internal
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Services internal interface to PDump device memory management
functions that are shared between client and server code.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef DEVICEMEM_PDUMP_H
#define DEVICEMEM_PDUMP_H
#include "devicemem.h"
#include "pdumpdefs.h"
#include "pdump.h"
#if defined(PDUMP)
/*
* DevmemPDumpLoadMem()
*
* takes a memory descriptor, offset, and size, and takes the current contents
* of the memory at that location and writes it to the prm pdump file, and
* emits a pdump LDB to load the data from that file. The intention here is
* that the contents of the simulated buffer upon pdump playback will be made
* to be the same as they are when this command is run, enabling pdump of
* cases where the memory has been modified externally, i.e. by the host cpu
* or by a third party.
*/
void
DevmemPDumpLoadMem(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize,
PDUMP_FLAGS_T uiPDumpFlags);
/*
* DevmemPDumpLoadZeroMem()
*
* As DevmemPDumpLoadMem() but the PDump allocation will be populated with
* zeros from the zero page in the parameter stream
*/
void
DevmemPDumpLoadZeroMem(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize,
PDUMP_FLAGS_T uiPDumpFlags);
/*
* DevmemPDumpLoadMemValue32()
*
* As above but dumps the value at a dword-aligned address in plain text to
* the pdump script2 file. Useful for patching a buffer at pdump playback by
* simply editing the script output file.
*
* (The same functionality can be achieved by the above function but the
* binary PARAM file must be patched in that case.)
*/
IMG_INTERNAL void
DevmemPDumpLoadMemValue32(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_UINT32 ui32Value,
PDUMP_FLAGS_T uiPDumpFlags);
/*
* DevmemPDumpMemValue64()
*
* As above but dumps the 64bit-value at a dword-aligned address in plain text
* to the pdump script2 file. Useful for patching a buffer at pdump playback by
* simply editing the script output file.
*
* (The same functionality can be achieved by the above function but the
* binary PARAM file must be patched in that case.)
*/
IMG_INTERNAL void
DevmemPDumpLoadMemValue64(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_UINT64 ui64Value,
PDUMP_FLAGS_T uiPDumpFlags);
/*
* DevmemPDumpPageCatBaseToSAddr()
*
* Returns the symbolic address of a piece of memory represented by an offset
* into the mem descriptor.
*/
PVRSRV_ERROR
DevmemPDumpPageCatBaseToSAddr(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T *puiMemOffset,
IMG_CHAR *pszName,
IMG_UINT32 ui32Size);
/*
* DevmemPDumpSaveToFile()
*
* Emits a pdump SAB to cause the current contents of the memory to be written
* to the given file during playback
*/
void
DevmemPDumpSaveToFile(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize,
const IMG_CHAR *pszFilename,
IMG_UINT32 uiFileOffset);
/*
* DevmemPDumpSaveToFileVirtual()
*
* Emits a pdump SAB, just like DevmemPDumpSaveToFile(), but uses the virtual
* address and device MMU context to cause the pdump player to traverse the
* MMU page tables itself.
*/
void
DevmemPDumpSaveToFileVirtual(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize,
const IMG_CHAR *pszFilename,
IMG_UINT32 ui32FileOffset,
IMG_UINT32 ui32PdumpFlags);
/*
* DevmemPDumpDataDescriptor()
*
* Emits a pdump CMD:OutputData, using the virtual address and device MMU
* context. Provides more flexibility than a pdump SAB because metadata can
* be passed to an external pdump player library via the command header.
*/
void
DevmemPDumpDataDescriptor(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize,
const IMG_CHAR *pszFilename,
IMG_UINT32 ui32HeaderType,
IMG_UINT32 ui32ElementType,
IMG_UINT32 ui32ElementCount,
IMG_UINT32 ui32PdumpFlags);
/*
*
* DevmemPDumpDevmemPol32()
*
* Writes a PDump 'POL' command to wait for a masked 32-bit memory location to
* become the specified value.
*/
PVRSRV_ERROR
DevmemPDumpDevmemPol32(const DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_UINT32 ui32Value,
IMG_UINT32 ui32Mask,
PDUMP_POLL_OPERATOR eOperator,
PDUMP_FLAGS_T ui32PDumpFlags);
#if defined(__KERNEL__)
/*
*
* DevmemPDumpDevmemCheck32()
*
* Writes a PDump 'POL' command to run a single-shot check for a masked
* 32-bit memory location to match the specified value.
*/
PVRSRV_ERROR
DevmemPDumpDevmemCheck32(const DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_UINT32 ui32Value,
IMG_UINT32 ui32Mask,
PDUMP_POLL_OPERATOR eOperator,
PDUMP_FLAGS_T ui32PDumpFlags);
#endif
/*
* DevmemPDumpCBP()
*
* Polls for space in circular buffer. Reads the read offset from memory and
* waits until there is enough space to write the packet.
*
* psMemDesc - MemDesc which contains the read offset
* uiReadOffset - Offset into MemDesc to the read offset
* uiWriteOffset - Current write offset
* uiPacketSize - Size of packet to write
* uiBufferSize - Size of circular buffer
*/
PVRSRV_ERROR
DevmemPDumpCBP(const DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiReadOffset,
IMG_DEVMEM_OFFSET_T uiWriteOffset,
IMG_DEVMEM_SIZE_T uiPacketSize,
IMG_DEVMEM_SIZE_T uiBufferSize);
#else /* PDUMP */
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemPDumpLoadMem)
#endif
static INLINE void
DevmemPDumpLoadMem(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize,
PDUMP_FLAGS_T uiPDumpFlags)
{
PVR_UNREFERENCED_PARAMETER(psMemDesc);
PVR_UNREFERENCED_PARAMETER(uiOffset);
PVR_UNREFERENCED_PARAMETER(uiSize);
PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
}
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemPDumpLoadMemValue32)
#endif
static INLINE void
DevmemPDumpLoadMemValue32(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_UINT32 ui32Value,
PDUMP_FLAGS_T uiPDumpFlags)
{
PVR_UNREFERENCED_PARAMETER(psMemDesc);
PVR_UNREFERENCED_PARAMETER(uiOffset);
PVR_UNREFERENCED_PARAMETER(ui32Value);
PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
}
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemPDumpLoadMemValue64)
#endif
static INLINE void
DevmemPDumpLoadMemValue64(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_UINT64 ui64Value,
PDUMP_FLAGS_T uiPDumpFlags)
{
PVR_UNREFERENCED_PARAMETER(psMemDesc);
PVR_UNREFERENCED_PARAMETER(uiOffset);
PVR_UNREFERENCED_PARAMETER(ui64Value);
PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
}
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemPDumpPageCatBaseToSAddr)
#endif
static INLINE PVRSRV_ERROR
DevmemPDumpPageCatBaseToSAddr(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T *puiMemOffset,
IMG_CHAR *pszName,
IMG_UINT32 ui32Size)
{
PVR_UNREFERENCED_PARAMETER(psMemDesc);
PVR_UNREFERENCED_PARAMETER(puiMemOffset);
PVR_UNREFERENCED_PARAMETER(pszName);
PVR_UNREFERENCED_PARAMETER(ui32Size);
return PVRSRV_OK;
}
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemPDumpSaveToFile)
#endif
static INLINE void
DevmemPDumpSaveToFile(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize,
const IMG_CHAR *pszFilename,
IMG_UINT32 uiFileOffset)
{
PVR_UNREFERENCED_PARAMETER(psMemDesc);
PVR_UNREFERENCED_PARAMETER(uiOffset);
PVR_UNREFERENCED_PARAMETER(uiSize);
PVR_UNREFERENCED_PARAMETER(pszFilename);
PVR_UNREFERENCED_PARAMETER(uiFileOffset);
}
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemPDumpSaveToFileVirtual)
#endif
static INLINE void
DevmemPDumpSaveToFileVirtual(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_DEVMEM_SIZE_T uiSize,
const IMG_CHAR *pszFilename,
IMG_UINT32 ui32FileOffset,
IMG_UINT32 ui32PdumpFlags)
{
PVR_UNREFERENCED_PARAMETER(psMemDesc);
PVR_UNREFERENCED_PARAMETER(uiOffset);
PVR_UNREFERENCED_PARAMETER(uiSize);
PVR_UNREFERENCED_PARAMETER(pszFilename);
PVR_UNREFERENCED_PARAMETER(ui32FileOffset);
PVR_UNREFERENCED_PARAMETER(ui32PdumpFlags);
}
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemPDumpDevmemPol32)
#endif
static INLINE PVRSRV_ERROR
DevmemPDumpDevmemPol32(const DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_UINT32 ui32Value,
IMG_UINT32 ui32Mask,
PDUMP_POLL_OPERATOR eOperator,
PDUMP_FLAGS_T ui32PDumpFlags)
{
PVR_UNREFERENCED_PARAMETER(psMemDesc);
PVR_UNREFERENCED_PARAMETER(uiOffset);
PVR_UNREFERENCED_PARAMETER(ui32Value);
PVR_UNREFERENCED_PARAMETER(ui32Mask);
PVR_UNREFERENCED_PARAMETER(eOperator);
PVR_UNREFERENCED_PARAMETER(ui32PDumpFlags);
return PVRSRV_OK;
}
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemPDumpCBP)
#endif
static INLINE PVRSRV_ERROR
DevmemPDumpCBP(const DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiReadOffset,
IMG_DEVMEM_OFFSET_T uiWriteOffset,
IMG_DEVMEM_SIZE_T uiPacketSize,
IMG_DEVMEM_SIZE_T uiBufferSize)
{
PVR_UNREFERENCED_PARAMETER(psMemDesc);
PVR_UNREFERENCED_PARAMETER(uiReadOffset);
PVR_UNREFERENCED_PARAMETER(uiWriteOffset);
PVR_UNREFERENCED_PARAMETER(uiPacketSize);
PVR_UNREFERENCED_PARAMETER(uiBufferSize);
return PVRSRV_OK;
}
#endif /* PDUMP */
#endif /* DEVICEMEM_PDUMP_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,793 @@
/*************************************************************************/ /*!
@File
@Title Device Memory Management
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Server side component for device memory management
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef DEVICEMEM_SERVER_H
#define DEVICEMEM_SERVER_H
#include "device.h" /* For device node */
#include "img_types.h"
#include "img_defs.h"
#include "pvr_debug.h"
#include "pvrsrv_error.h"
#include "connection_server.h"
#include "pmr.h"
/*
* DevmemServerGetImportHandle()
*
* For given exportable memory descriptor returns PMR handle
*
*/
PVRSRV_ERROR
DevmemServerGetImportHandle(DEVMEM_MEMDESC *psMemDesc,
IMG_HANDLE *phImport);
/*
* DevmemServerGetHeapHandle()
*
* For given reservation returns the Heap handle
*
*/
PVRSRV_ERROR
DevmemServerGetHeapHandle(DEVMEMINT_RESERVATION *psReservation,
IMG_HANDLE *phHeap);
/*
* DevmemServerGetContext()
*
* For given heap returns the context.
*
*/
PVRSRV_ERROR
DevmemServerGetContext(DEVMEMINT_HEAP *psDevmemHeap,
DEVMEMINT_CTX **ppsDevmemCtxPtr);
/*
* DevmemServerGetPrivData()
*
* For given context returns the private data handle.
*
*/
PVRSRV_ERROR
DevmemServerGetPrivData(DEVMEMINT_CTX *psDevmemCtx,
IMG_HANDLE *phPrivData);
/*
* DevmemIntCtxCreate()
*
* Create a Server-side Device Memory Context. This is usually the counterpart
* of the client side memory context, and indeed is usually created at the
* same time.
*
* You must have one of these before creating any heaps.
*
* All heaps must have been destroyed before calling
* DevmemIntCtxDestroy()
*
* If you call DevmemIntCtxCreate() (and it succeeds) you are promising to
* later call DevmemIntCtxDestroy()
*
* Note that this call will cause the device MMU code to do some work for
* creating the device memory context, but it does not guarantee that a page
* catalogue will have been created, as this may be deferred until the first
* allocation.
*
* Caller to provide storage for a pointer to the DEVMEM_CTX object that will
* be created by this call.
*/
PVRSRV_ERROR
DevmemIntCtxCreate(CONNECTION_DATA *psConnection,
PVRSRV_DEVICE_NODE *psDeviceNode,
/* devnode / perproc etc */
IMG_BOOL bKernelMemoryCtx,
DEVMEMINT_CTX **ppsDevmemCtxPtr,
IMG_HANDLE *hPrivData,
IMG_UINT32 *pui32CPUCacheLineSize);
/*
* DevmemIntCtxDestroy()
*
* Undoes a prior DevmemIntCtxCreate or DevmemIntCtxImport.
*/
PVRSRV_ERROR
DevmemIntCtxDestroy(DEVMEMINT_CTX *psDevmemCtx);
/*
* DevmemIntCtxRef()
*
* Increases the reference count on the given DEVMEMINT_CTX by one.
*/
PVRSRV_ERROR DevmemIntCtxRef(DEVMEMINT_CTX *psDevmemCtx);
/*
* DevmemIntCtxUnref()
*
* Decreases the reference count on the given DEVMEMINT_CTX by one.
*/
void DevmemIntCtxUnref(DEVMEMINT_CTX *psDevmemCtx);
/*
* DevmemIntHeapCreate()
*
* Creates a new heap in this device memory context. This will cause a call
* into the MMU code to allocate various data structures for managing this
* heap. It will not necessarily cause any page tables to be set up, as this
* can be deferred until first allocation. (i.e. we shouldn't care - it's up
* to the MMU code)
*
* Note that the data page size must be specified (as log 2). The data page
* size as specified here will be communicated to the mmu module, and thus may
* determine the page size configured in page directory entries for subsequent
* allocations from this heap. It is essential that the page size here is less
* than or equal to the "minimum contiguity guarantee" of any PMR that you
* subsequently attempt to map to this heap.
*
* If you call DevmemIntHeapCreate() (and the call succeeds) you are promising
* that you shall subsequently call DevmemIntHeapDestroy()
*
* Caller to provide storage for a pointer to the DEVMEM_HEAP object that will
* be created by this call.
*/
PVRSRV_ERROR
DevmemIntHeapCreate(DEVMEMINT_CTX *psDevmemCtx,
IMG_UINT32 uiHeapConfigIndex,
IMG_UINT32 uiHeapIndex,
DEVMEMINT_HEAP **ppsDevmemHeapPtr);
/*
* DevmemIntHeapDestroy()
*
* Destroys a heap previously created with DevmemIntHeapCreate()
*
* All allocations from his heap must have been freed before this
* call.
*/
PVRSRV_ERROR
DevmemIntHeapDestroy(DEVMEMINT_HEAP *psDevmemHeap);
/* DevmemIntHeapGetBaseAddr()
*
* Get heap base address pre carveouts.
*/
IMG_DEV_VIRTADDR
DevmemIntHeapGetBaseAddr(DEVMEMINT_HEAP *psDevmemHeap);
/*************************************************************************/ /*!
* @Function DevmemIntReserveRange()
* @Description Reserves a number of virtual addresses starting sReservationVAddr
* and continuing until sReservationVAddr + uiVirtualSize - 1.
*
* If you call DevmemIntReserveRange() (and the call succeeds)
* then you are promising that you shall later call DevmemIntUnreserveRange()
*
* @Input psConnectionData The connection data from the bridge. Used
* to determine where the call to this function
* originated from.
* @Input psDeviceNode The device node (unused).
* @Input psDevmemHeap The virtual heap the DevVAddr is within.
* @Input sReservationVAddr The first virtual address of the range.
* @Input uiVirtualSize The number of bytes in the virtual range.
* @Input uiFlags Mem alloc flags
* @Output ppsReservationPtr A pointer to the created reservation.
*
* @Return PVRSRV_ERROR
*/ /**************************************************************************/
PVRSRV_ERROR
DevmemIntReserveRange(CONNECTION_DATA *psConnectionData,
PVRSRV_DEVICE_NODE *psDeviceNode,
DEVMEMINT_HEAP *psDevmemHeap,
IMG_DEV_VIRTADDR sReservationVAddr,
IMG_DEVMEM_SIZE_T uiVirtualSize,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
DEVMEMINT_RESERVATION **ppsReservationPtr);
/*************************************************************************/ /*!
* @Function DevmemIntUnreserveRange()
* @Description Unreserves the specified virtual range. In the case that the
* virtual range has not been unmapped, it will be unmapped.
* If any references are held on the reservation PVRSRV_ERROR_RETRY
* will be returned.
*
* @Input psDevmemReservation The reservation to unreserve
*
* @Return PVRSRV_ERROR
*/ /**************************************************************************/
PVRSRV_ERROR
DevmemIntUnreserveRange(DEVMEMINT_RESERVATION *psDevmemReservation);
/*************************************************************************/ /*!
* @Function DevmemIntMapPMR
*
* @Description Maps the given PMR to the virtual range previously reserved with
* DevmemIntReserveRange(). When calling this function, the reservation
* must be valid, and not mapped. Additionally, the PMRs logical
* size and the reservations virtual size must be equal.
*
* If appropriate, the PMR must have had its physical backing
* committed, as this call will call into the MMU code to set
* up the page tables for this allocation, which shall in turn
* request the physical addresses from the PMR. Alternatively,
* the PMR implementation can choose to do so off the back of
* the "lock" callback, which it will receive as a result
* (indirectly) of this call.
*
* If you call DevmemIntMapPMR() (and the call succeeds) then you
* are promising that you shall later call DevmemIntUnmapPMR()
*
* @Input psReservation The reservation the PMR will be mapped into.
* @Input psPMR The PMR to be mapped.
*
* @Return PVRSRV_ERROR failure code
*/ /**************************************************************************/
PVRSRV_ERROR
DevmemIntMapPMR(DEVMEMINT_RESERVATION *psReservation, PMR *psPMR);
#if defined(SUPPORT_LINUX_OSPAGE_MIGRATION)
/*************************************************************************/ /*!
* @Function DevmemIntRemapPageInPMR
*
* @Description Distributes calls to the MMU module to remap a given PMR
* page offset into all associated mappings.
*
* @Input psPMR The PMR to be mapped.
* @Input psMappingListHead The mapping node list head where nodes are
* associated with the PMR via calls to
* PMRLinkGPUMapping.
* Expected type:
* DLLIST_NODE list head from the PMR
* (sGpuMappingListHead)
* @Input ui32LogicalPgOffset The logical page offset into the
* PMR and reservation.
*
* @Return PVRSRV_ERROR failure code.
* PVRSRV_ERROR_DEVICEMEM_REJECT_REMAP_REQUEST can be returned
* if remap is not possible on the given page offset.
*/ /**************************************************************************/
PVRSRV_ERROR
DevmemIntRemapPageInPMR(PMR *psPMR, DLLIST_NODE *psMappingListHead, IMG_UINT32 ui32LogicalPgOffset);
#endif
/*************************************************************************/ /*!
* @Function DevmemIntUnmapPMR()
*
* @Description Unmaps a previously mapped virtual range.
*
* @Input psReservation The virtual range to unmap.
*
* @Return PVRSRV_ERROR
*/ /**************************************************************************/
PVRSRV_ERROR
DevmemIntUnmapPMR(DEVMEMINT_RESERVATION *psReservation);
/*************************************************************************/ /*!
* @Function DevmemIntReserveRangeAndMapPMR()
*
* @Description Reserve (with DevmemIntReserveRange), and map a virtual range
* to a PMR (with DevmemIntMapPMR).
*
* @Input psConnectionData The connection data from the bridge. Used
* to determine where the call to this function
* originated from.
* @Input psDeviceNode The device node.
* @Input psDevmemHeap The virtual heap DevVAddr is within.
* @Input sReservationVAddr The first virtual address of the range.
* @Input uiVirtualSize The number of bytes in the virtual range.
* @Input psPMR The PMR to be mapped.
* @Input uiFlags Mem alloc flags
* @Output ppsReservation A pointer to the created reservation.
*
* @Return PVRSRV_ERROR
*/ /**************************************************************************/
PVRSRV_ERROR
DevmemIntReserveRangeAndMapPMR(CONNECTION_DATA *psConnectionData,
PVRSRV_DEVICE_NODE *psDeviceNode,
DEVMEMINT_HEAP *psDevmemHeap,
IMG_DEV_VIRTADDR sReservationVAddr,
IMG_DEVMEM_SIZE_T uiVirtualSize,
PMR *psPMR,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
DEVMEMINT_RESERVATION **ppsReservation);
/*************************************************************************/ /*!
* @Function DevmemIntChangeSparse
* @Description Changes the sparse allocations of a PMR by allocating and freeing
* pages and changing their corresponding GPU mapping.
*
* Prior to calling this function DevmemIntMapPMR
* or DevmemIntReserveRangeAndMapPMR must be used.
*
* @Input psReservation The reservation that the PMR is mapped to.
* @Input ui32AllocPageCount Number of pages to allocate
* @Input pai32AllocIndices The logical PMR indices where pages will
* be allocated. May be NULL.
* @Input ui32FreePageCount Number of pages to free
* @Input pai32FreeIndices The logical PMR indices where pages will
* be freed. May be NULL.
* @Input uiSparseFlags Flags passed in to determine which kind
* of sparse change the user wanted.
* See devicemem_typedefs.h for details.
* @Return PVRSRV_ERROR
*/ /**************************************************************************/
PVRSRV_ERROR
DevmemIntChangeSparse(IMG_UINT32 ui32AllocPageCount,
IMG_UINT32 *pai32AllocIndices,
IMG_UINT32 ui32FreePageCount,
IMG_UINT32 *pai32FreeIndices,
SPARSE_MEM_RESIZE_FLAGS uiSparseFlags,
DEVMEMINT_RESERVATION *psReservation);
PVRSRV_ERROR
DevmemIntGetReservationData(DEVMEMINT_RESERVATION* psReservation, PMR** ppsPMR, IMG_DEV_VIRTADDR* psDevVAddr);
/*************************************************************************/ /*!
* @Function DevmemXIntReserveRange()
* @Description Indicates that the specified range should be reserved from the
* given heap.
*
* In turn causes the page tables to be allocated to cover the
* specified range.
*
* If you call DevmemIntReserveRange() (and the call succeeds)
* then you are promising that you shall later call
* DevmemIntUnreserveRange().
*
* @Input psDevmemHeap Pointer to the heap the reservation is made
* on
* @Input sReservationVAddr Virtual address of the reservation
* @Input uiVirtualSize Size of the reservation (in bytes)
* @Input ppsRsrv Return pointer to the reservation object
*
* @Return PVRSRV_ERROR
*/ /**************************************************************************/
PVRSRV_ERROR
DevmemXIntReserveRange(DEVMEMINT_HEAP *psDevmemHeap,
IMG_DEV_VIRTADDR sReservationVAddr,
IMG_DEVMEM_SIZE_T uiVirtualSize,
DEVMEMXINT_RESERVATION **ppsRsrv);
/*************************************************************************/ /*!
* @Function DevmemXIntUnreserveRange()
* @Description Undoes the state change caused by DevmemXIntReserveRage()
*
* @Input psRsrv Reservation handle for the range
*
* @Return PVRSRV_ERROR
*/ /**************************************************************************/
PVRSRV_ERROR
DevmemXIntUnreserveRange(DEVMEMXINT_RESERVATION *psRsrv);
/*************************************************************************/ /*!
@Function DevmemIntReservationAcquire
@Description Acquire a reference to the provided device memory reservation.
Prevents releasing of the reservation if external device
resource components still require it.
@Return IMG_TRUE if referenced and IMG_FALSE in case of error
*/ /**************************************************************************/
IMG_BOOL
DevmemIntReservationAcquire(DEVMEMINT_RESERVATION *psDevmemReservation);
/*************************************************************************/ /*!
@Function DevmemIntReservationRelease
@Description Release the reference to the provided device memory reservation.
Once these references have been released the
reservation is allowed to be released from UM.
@Return None.
*/ /**************************************************************************/
void
DevmemIntReservationRelease(DEVMEMINT_RESERVATION *psDevmemReservation);
/*************************************************************************/ /*!
* @Function DevmemXIntMapPages()
* @Description Maps an arbitrary amount of pages from a PMR to a reserved range
* and takes references on the PMR.
*
* @Input psRsrv Reservation handle for the range
* @Input psPMR PMR that is mapped
* @Input uiPageCount Number of consecutive pages that are
* mapped
* @Input uiPhysPageOffset Logical offset in the PMR (measured in pages)
* @Input uiFlags Mapping flags
* @Input uiVirtPageOffset Offset from the reservation base to start the
* mapping from (measured in pages)
*
* @Return PVRSRV_ERROR
*/ /**************************************************************************/
PVRSRV_ERROR
DevmemXIntMapPages(DEVMEMXINT_RESERVATION *psRsrv,
PMR *psPMR,
IMG_UINT32 uiPageCount,
IMG_UINT32 uiPhysPageOffset,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
IMG_UINT32 uiVirtPageOffset);
/*************************************************************************/ /*!
* @Function DevmemXIntUnmapPages()
* @Description Unmaps an arbitrary amount of pages from a reserved range and
* releases references on associated PMRs.
*
* @Input psRsrv Reservation handle for the range
* @Input uiVirtPageOffset Offset from the reservation base to start the
* mapping from (measured in pages)
* @Input uiPageCount Number of consecutive pages that are
* unmapped
*
* @Return PVRSRV_ERROR
*/ /**************************************************************************/
PVRSRV_ERROR
DevmemXIntUnmapPages(DEVMEMXINT_RESERVATION *psRsrv,
IMG_UINT32 uiVirtPageOffset,
IMG_UINT32 uiPageCount);
/*************************************************************************/ /*!
* @Function DevmemXIntMapVRangeToBackingPage()
* @Description Maps a kernel internal backing page to a reserved range.
*
* @Input psRsrv Reservation handle for the range
* @Input uiPageCount Number of consecutive pages that are
* mapped
* @Input uiFlags Mapping flags
* @Input uiVirtPageOffset Offset from the reservation base to start the
* mapping from (measured in pages)
*
* @Return PVRSRV_ERROR
*/ /**************************************************************************/
PVRSRV_ERROR
DevmemXIntMapVRangeToBackingPage(DEVMEMXINT_RESERVATION *psRsrv,
IMG_UINT32 uiPageCount,
PVRSRV_MEMALLOCFLAGS_T uiFlags,
IMG_UINT32 uiVirtPageOffset);
/*
* DevmemIntInvalidateFBSCTable()
*
* Invalidate selected FBSC table indices.
*
*/
PVRSRV_ERROR
DevmemIntInvalidateFBSCTable(DEVMEMINT_CTX *psDevmemCtx,
IMG_UINT64 ui64FBSCEntryMask);
PVRSRV_ERROR
DevmemIntIsVDevAddrValid(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE *psDevNode,
DEVMEMINT_CTX *psDevMemContext,
IMG_DEV_VIRTADDR sDevAddr);
PVRSRV_ERROR
DevmemIntGetFaultAddress(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE *psDevNode,
DEVMEMINT_CTX *psDevMemContext,
IMG_DEV_VIRTADDR *psFaultAddress);
/*************************************************************************/ /*!
@Function DevmemIntRegisterPFNotifyKM
@Description Registers a PID to be notified when a page fault occurs on a
specific device memory context.
@Input psDevmemCtx The context to be notified about.
@Input bRegister If true, register. If false, de-register.
@Return PVRSRV_ERROR
*/ /**************************************************************************/
PVRSRV_ERROR
DevmemIntRegisterPFNotifyKM(DEVMEMINT_CTX *psDevmemCtx,
IMG_BOOL bRegister);
/*************************************************************************/ /*!
@Function DevmemIntPFNotify
@Description Notifies any processes that have registered themselves to be
notified when a page fault happens on a specific device memory
context.
@Input *psDevNode The device node.
@Input ui64FaultedPCAddress The page catalogue address that faulted.
@Input sFaultAddress The address that triggered the fault.
@Return PVRSRV_ERROR
*/ /**************************************************************************/
PVRSRV_ERROR DevmemIntPFNotify(PVRSRV_DEVICE_NODE *psDevNode,
IMG_UINT64 ui64FaultedPCAddress,
IMG_DEV_VIRTADDR sFaultAddress);
#if defined(PDUMP)
PVRSRV_ERROR
DevmemIntPDumpGetValidRegions(CONNECTION_DATA *psConnection,
PVRSRV_DEVICE_NODE *psDeviceNode,
DEVMEMINT_CTX *psDevmemCtx,
IMG_DEV_VIRTADDR sDevAddrStart,
IMG_DEVMEM_SIZE_T uiSize,
DLLIST_NODE *psValidRegionsList);
void
DevmemIntPDumpFreeValidRegions(DLLIST_NODE *psValidRegionsList);
PVRSRV_ERROR
DevmemIntPDumpSaveFromRegionListToFileVirtual(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE *psDeviceNode,
DEVMEMINT_CTX *psDevmemCtx,
DLLIST_NODE *psDevAddrRegions,
const IMG_CHAR *pszFilename,
IMG_UINT32 ui32FileOffset,
IMG_UINT32 ui32PDumpFlags);
/*
* DevmemIntPDumpSaveToFileVirtual()
*
* Writes out PDump "SAB" commands with the data found in memory at
* the given virtual address.
*/
PVRSRV_ERROR
DevmemIntPDumpSaveToFileVirtual(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE *psDeviceNode,
DEVMEMINT_CTX *psDevmemCtx,
IMG_DEV_VIRTADDR sDevAddrStart,
IMG_DEVMEM_SIZE_T uiSize,
IMG_UINT32 uiArraySize,
const IMG_CHAR *pszFilename,
IMG_UINT32 ui32FileOffset,
IMG_UINT32 ui32PDumpFlags);
/*
* DevmemIntPDumpSaveToFileVirtualNoValidate()
*
* Writes out PDump "SAB" commands with the data found in memory at
* the given virtual address. Doesn't perform address validation.
*/
PVRSRV_ERROR
DevmemIntPDumpSaveToFileVirtualNoValidate(PVRSRV_DEVICE_NODE *psDeviceNode,
DEVMEMINT_CTX *psDevmemCtx,
IMG_DEV_VIRTADDR sDevAddrStart,
IMG_DEVMEM_SIZE_T uiSize,
const IMG_CHAR *pszFilename,
IMG_UINT32 ui32FileOffset,
IMG_UINT32 ui32PDumpFlags);
IMG_UINT32
DevmemIntMMUContextID(DEVMEMINT_CTX *psDevMemContext);
PVRSRV_ERROR
DevmemIntPDumpImageDescriptor(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE *psDeviceNode,
DEVMEMINT_CTX *psDevMemContext,
IMG_UINT32 ui32Size,
const IMG_CHAR *pszFileName,
IMG_DEV_VIRTADDR sData,
IMG_UINT32 ui32DataSize,
IMG_UINT32 ui32LogicalWidth,
IMG_UINT32 ui32LogicalHeight,
IMG_UINT32 ui32PhysicalWidth,
IMG_UINT32 ui32PhysicalHeight,
PDUMP_PIXEL_FORMAT ePixFmt,
IMG_MEMLAYOUT eMemLayout,
IMG_FB_COMPRESSION eFBCompression,
const IMG_UINT32 *paui32FBCClearColour,
PDUMP_FBC_SWIZZLE eFBCSwizzle,
IMG_DEV_VIRTADDR sHeader,
IMG_UINT32 ui32HeaderSize,
IMG_UINT32 ui32PDumpFlags);
PVRSRV_ERROR
DevmemIntPDumpDataDescriptor(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE *psDeviceNode,
DEVMEMINT_CTX *psDevMemContext,
IMG_UINT32 ui32Size,
const IMG_CHAR *pszFileName,
IMG_DEV_VIRTADDR sData,
IMG_UINT32 ui32DataSize,
IMG_UINT32 ui32HeaderType,
IMG_UINT32 ui32ElementType,
IMG_UINT32 ui32ElementCount,
IMG_UINT32 ui32PDumpFlags);
#else /* PDUMP */
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemIntPDumpGetValidRegions)
#endif
static INLINE PVRSRV_ERROR
DevmemIntPDumpGetValidRegions(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE *psDeviceNode,
DEVMEMINT_CTX *psDevmemCtx,
IMG_DEV_VIRTADDR sDevAddrStart,
IMG_DEVMEM_SIZE_T uiSize)
{
PVR_UNREFERENCED_PARAMETER(psConnection);
PVR_UNREFERENCED_PARAMETER(psDeviceNode);
PVR_UNREFERENCED_PARAMETER(psDevmemCtx);
PVR_UNREFERENCED_PARAMETER(sDevAddrStart);
PVR_UNREFERENCED_PARAMETER(uiSize);
return PVRSRV_OK;
}
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemIntPDumpFreeValidRegions)
#endif
static INLINE void
DevmemIntPDumpFreeValidRegions(DLLIST_NODE *psDevAddrRegions)
{
PVR_UNREFERENCED_PARAMETER(psDevAddrRegions);
}
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemIntPDumpSaveFromRegionListToFileVirtual)
#endif
static INLINE PVRSRV_ERROR
DevmemIntPDumpSaveFromRegionListToFileVirtual(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE *psDeviceNode,
DEVMEMINT_CTX *psDevmemCtx,
DLLIST_NODE *psDevAddrRegions,
const IMG_CHAR *pszFilename,
IMG_UINT32 ui32FileOffset,
IMG_UINT32 ui32PDumpFlags)
{
PVR_UNREFERENCED_PARAMETER(psConnection);
PVR_UNREFERENCED_PARAMETER(psDeviceNode);
PVR_UNREFERENCED_PARAMETER(psDevmemCtx);
PVR_UNREFERENCED_PARAMETER(psDevAddrRegions);
PVR_UNREFERENCED_PARAMETER(pszFilename);
PVR_UNREFERENCED_PARAMETER(ui32FileOffset);
PVR_UNREFERENCED_PARAMETER(ui32PDumpFlags);
return PVRSRV_OK;
}
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemIntPDumpSaveToFileVirtual)
#endif
static INLINE PVRSRV_ERROR
DevmemIntPDumpSaveToFileVirtual(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE *psDeviceNode,
DEVMEMINT_CTX *psDevmemCtx,
IMG_DEV_VIRTADDR sDevAddrStart,
IMG_DEVMEM_SIZE_T uiSize,
IMG_UINT32 uiArraySize,
const IMG_CHAR *pszFilename,
IMG_UINT32 ui32FileOffset,
IMG_UINT32 ui32PDumpFlags)
{
PVR_UNREFERENCED_PARAMETER(psConnection);
PVR_UNREFERENCED_PARAMETER(psDeviceNode);
PVR_UNREFERENCED_PARAMETER(psDevmemCtx);
PVR_UNREFERENCED_PARAMETER(sDevAddrStart);
PVR_UNREFERENCED_PARAMETER(uiSize);
PVR_UNREFERENCED_PARAMETER(uiArraySize);
PVR_UNREFERENCED_PARAMETER(pszFilename);
PVR_UNREFERENCED_PARAMETER(ui32FileOffset);
PVR_UNREFERENCED_PARAMETER(ui32PDumpFlags);
return PVRSRV_OK;
}
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemIntPDumpImageDescriptor)
#endif
static INLINE PVRSRV_ERROR
DevmemIntPDumpImageDescriptor(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE *psDeviceNode,
DEVMEMINT_CTX *psDevMemContext,
IMG_UINT32 ui32Size,
const IMG_CHAR *pszFileName,
IMG_DEV_VIRTADDR sData,
IMG_UINT32 ui32DataSize,
IMG_UINT32 ui32LogicalWidth,
IMG_UINT32 ui32LogicalHeight,
IMG_UINT32 ui32PhysicalWidth,
IMG_UINT32 ui32PhysicalHeight,
PDUMP_PIXEL_FORMAT ePixFmt,
IMG_MEMLAYOUT eMemLayout,
IMG_FB_COMPRESSION eFBCompression,
const IMG_UINT32 *paui32FBCClearColour,
PDUMP_FBC_SWIZZLE eFBCSwizzle,
IMG_DEV_VIRTADDR sHeader,
IMG_UINT32 ui32HeaderSize,
IMG_UINT32 ui32PDumpFlags)
{
PVR_UNREFERENCED_PARAMETER(psConnection);
PVR_UNREFERENCED_PARAMETER(psDeviceNode);
PVR_UNREFERENCED_PARAMETER(psDevMemContext);
PVR_UNREFERENCED_PARAMETER(ui32Size);
PVR_UNREFERENCED_PARAMETER(pszFileName);
PVR_UNREFERENCED_PARAMETER(sData);
PVR_UNREFERENCED_PARAMETER(ui32DataSize);
PVR_UNREFERENCED_PARAMETER(ui32LogicalWidth);
PVR_UNREFERENCED_PARAMETER(ui32LogicalHeight);
PVR_UNREFERENCED_PARAMETER(ui32PhysicalWidth);
PVR_UNREFERENCED_PARAMETER(ui32PhysicalHeight);
PVR_UNREFERENCED_PARAMETER(ePixFmt);
PVR_UNREFERENCED_PARAMETER(eMemLayout);
PVR_UNREFERENCED_PARAMETER(eFBCompression);
PVR_UNREFERENCED_PARAMETER(paui32FBCClearColour);
PVR_UNREFERENCED_PARAMETER(eFBCSwizzle);
PVR_UNREFERENCED_PARAMETER(sHeader);
PVR_UNREFERENCED_PARAMETER(ui32HeaderSize);
PVR_UNREFERENCED_PARAMETER(ui32PDumpFlags);
return PVRSRV_OK;
}
#ifdef INLINE_IS_PRAGMA
#pragma inline(DevmemIntPDumpDataDescriptor)
#endif
static INLINE PVRSRV_ERROR
DevmemIntPDumpDataDescriptor(CONNECTION_DATA * psConnection,
PVRSRV_DEVICE_NODE *psDeviceNode,
DEVMEMINT_CTX *psDevMemContext,
IMG_UINT32 ui32Size,
const IMG_CHAR *pszFileName,
IMG_DEV_VIRTADDR sData,
IMG_UINT32 ui32DataSize,
IMG_UINT32 ui32ElementType,
IMG_UINT32 ui32ElementCount,
IMG_UINT32 ui32PDumpFlags)
{
PVR_UNREFERENCED_PARAMETER(psConnection);
PVR_UNREFERENCED_PARAMETER(psDeviceNode);
PVR_UNREFERENCED_PARAMETER(psDevMemContext);
PVR_UNREFERENCED_PARAMETER(ui32Size);
PVR_UNREFERENCED_PARAMETER(pszFileName);
PVR_UNREFERENCED_PARAMETER(sData);
PVR_UNREFERENCED_PARAMETER(ui32DataSize);
PVR_UNREFERENCED_PARAMETER(ui32ElementType);
PVR_UNREFERENCED_PARAMETER(ui32ElementCount);
PVR_UNREFERENCED_PARAMETER(ui32PDumpFlags);
return PVRSRV_OK;
}
#endif /* PDUMP */
PVRSRV_ERROR
DevmemIntInit(void);
PVRSRV_ERROR
DevmemIntDeInit(void);
PVRSRV_ERROR
DevmemIntExportCtx(DEVMEMINT_CTX *psContext,
PMR *psPMR,
DEVMEMINT_CTX_EXPORT **ppsContextExport);
PVRSRV_ERROR
DevmemIntUnexportCtx(DEVMEMINT_CTX_EXPORT *psContextExport);
PVRSRV_ERROR
DevmemIntAcquireRemoteCtx(PMR *psPMR,
DEVMEMINT_CTX **ppsContext,
IMG_HANDLE *phPrivData);
#endif /* DEVICEMEM_SERVER_H */

View File

@@ -0,0 +1,179 @@
/**************************************************************************/ /*!
@File
@Title Device Memory Management
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Header file utilities that are specific to device memory functions
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /***************************************************************************/
#include "img_defs.h"
#include "img_types.h"
#include "device.h"
#include "pvrsrv_memallocflags.h"
#include "pvrsrv.h"
static INLINE PVRSRV_ERROR DevmemCPUCacheMode(PVRSRV_MEMALLOCFLAGS_T ulFlags,
IMG_UINT32 *pui32Ret)
{
IMG_UINT32 ui32CPUCacheMode = PVRSRV_CPU_CACHE_MODE(ulFlags);
IMG_UINT32 ui32Ret;
PVRSRV_ERROR eError = PVRSRV_OK;
PVR_ASSERT(ui32CPUCacheMode == PVRSRV_CPU_CACHE_MODE(ulFlags));
switch (ui32CPUCacheMode)
{
case PVRSRV_MEMALLOCFLAG_CPU_UNCACHED:
ui32Ret = PVRSRV_MEMALLOCFLAG_CPU_UNCACHED;
break;
case PVRSRV_MEMALLOCFLAG_CPU_UNCACHED_WC:
ui32Ret = PVRSRV_MEMALLOCFLAG_CPU_UNCACHED_WC;
break;
case PVRSRV_MEMALLOCFLAG_CPU_CACHE_INCOHERENT:
ui32Ret = PVRSRV_MEMALLOCFLAG_CPU_CACHED;
break;
case PVRSRV_MEMALLOCFLAG_CPU_CACHE_COHERENT:
/*
* If system has no coherency but coherency has been requested for CPU
* and GPU we currently fall back to write-combine.
* This avoids errors on arm64 when uncached is turned into ordered device memory
* and suffers from problems with unaligned access.
*/
if (PVRSRV_GPU_CACHE_MODE(ulFlags) == PVRSRV_MEMALLOCFLAG_GPU_CACHE_COHERENT)
{
ui32Ret = PVRSRV_MEMALLOCFLAG_CPU_UNCACHED_WC;
}
else
{
ui32Ret = PVRSRV_MEMALLOCFLAG_CPU_CACHED;
}
break;
default:
PVR_LOG(("DevmemCPUCacheMode: Unknown CPU cache mode 0x%08x", ui32CPUCacheMode));
PVR_ASSERT(0);
/*
We should never get here, but if we do then setting the mode
to uncached is the safest thing to do.
*/
ui32Ret = PVRSRV_MEMALLOCFLAG_CPU_UNCACHED;
eError = PVRSRV_ERROR_UNSUPPORTED_CACHE_MODE;
break;
}
*pui32Ret = ui32Ret;
return eError;
}
static INLINE PVRSRV_ERROR DevmemDeviceCacheMode(PVRSRV_MEMALLOCFLAGS_T ulFlags,
IMG_UINT32 *pui32Ret)
{
IMG_UINT32 ui32DeviceCacheMode = PVRSRV_GPU_CACHE_MODE(ulFlags);
IMG_UINT32 ui32Ret;
PVRSRV_ERROR eError = PVRSRV_OK;
PVR_ASSERT(ui32DeviceCacheMode == PVRSRV_GPU_CACHE_MODE(ulFlags));
switch (ui32DeviceCacheMode)
{
case PVRSRV_MEMALLOCFLAG_GPU_UNCACHED:
ui32Ret = PVRSRV_MEMALLOCFLAG_GPU_UNCACHED;
break;
case PVRSRV_MEMALLOCFLAG_GPU_UNCACHED_WC:
ui32Ret = PVRSRV_MEMALLOCFLAG_GPU_UNCACHED_WC;
break;
case PVRSRV_MEMALLOCFLAG_GPU_CACHE_INCOHERENT:
ui32Ret = PVRSRV_MEMALLOCFLAG_GPU_CACHED;
break;
case PVRSRV_MEMALLOCFLAG_GPU_CACHE_COHERENT:
/*
* If system has no coherency but coherency has been requested for CPU
* and GPU we currently fall back to write-combine.
* This avoids errors on arm64 when uncached is turned into ordered device memory
* and suffers from problems with unaligned access.
*/
if (PVRSRV_CPU_CACHE_MODE(ulFlags) == PVRSRV_MEMALLOCFLAG_CPU_CACHE_COHERENT)
{
ui32Ret = PVRSRV_MEMALLOCFLAG_GPU_UNCACHED_WC;
}
else
{
ui32Ret = PVRSRV_MEMALLOCFLAG_GPU_CACHED;
}
break;
default:
PVR_LOG(("DevmemDeviceCacheMode: Unknown device cache mode 0x%08x", ui32DeviceCacheMode));
PVR_ASSERT(0);
/*
We should never get here, but if we do then setting the mode
to uncached is the safest thing to do.
*/
ui32Ret = PVRSRV_MEMALLOCFLAG_GPU_UNCACHED;
eError = PVRSRV_ERROR_UNSUPPORTED_CACHE_MODE;
break;
}
*pui32Ret = ui32Ret;
return eError;
}
static INLINE IMG_BOOL DevmemDeviceCacheCoherency(PVRSRV_DEVICE_NODE *psDeviceNode,
PVRSRV_MEMALLOCFLAGS_T ulFlags)
{
IMG_UINT32 ui32DeviceCacheMode = PVRSRV_GPU_CACHE_MODE(ulFlags);
IMG_BOOL bRet = IMG_FALSE;
PVR_ASSERT(ui32DeviceCacheMode == PVRSRV_GPU_CACHE_MODE(ulFlags));
if (ui32DeviceCacheMode == PVRSRV_MEMALLOCFLAG_GPU_CACHE_COHERENT)
{
bRet = PVRSRVSystemSnoopingOfCPUCache(psDeviceNode->psDevConfig);
}
return bRet;
}

View File

@@ -0,0 +1,131 @@
/*************************************************************************/ /*!
@File
@Title Device Memory Management
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Client side part of device memory management -- this file
is forked from new_devmem_allocation.h as this one has to
reside in the top level include so that client code is able
to make use of the typedefs.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef DEVICEMEM_TYPEDEFS_H
#define DEVICEMEM_TYPEDEFS_H
#include <powervr/mem_types.h>
#include "img_types.h"
#include "pvrsrv_memallocflags.h"
typedef struct DEVMEM_CONTEXT_TAG DEVMEM_CONTEXT; /*!< Convenience typedef for struct DEVMEM_CONTEXT_TAG */
typedef struct DEVMEM_HEAP_TAG DEVMEM_HEAP; /*!< Convenience typedef for struct DEVMEM_HEAP_TAG */
typedef struct DEVMEM_MEMDESC_TAG DEVMEM_MEMDESC; /*!< Convenience typedef for struct DEVMEM_MEMDESC_TAG */
typedef struct DEVMEM_PAGELIST_TAG DEVMEM_PAGELIST; /*!< Convenience typedef for struct DEVMEM_PAGELIST_TAG */
typedef IMG_HANDLE DEVMEM_EXPORTHANDLE; /*!< Typedef for DeviceMem Export Handle */
typedef IMG_UINT64 DEVMEM_EXPORTKEY; /*!< Typedef for DeviceMem Export Key */
typedef IMG_DEVMEM_SIZE_T DEVMEM_SIZE_T; /*!< Typedef for DeviceMem SIZE_T */
typedef IMG_DEVMEM_LOG2ALIGN_T DEVMEM_LOG2ALIGN_T; /*!< Typedef for DeviceMem LOG2 Alignment */
typedef struct DEVMEMX_PHYS_MEMDESC_TAG DEVMEMX_PHYSDESC; /*!< Convenience typedef for DevmemX physical */
typedef struct DEVMEMX_VIRT_MEMDESC_TAG DEVMEMX_VIRTDESC; /*!< Convenience typedef for DevmemX virtual */
/*! calling code needs all the info in this struct, to be able to pass it around */
typedef struct
{
/*! A handle to the PMR. */
IMG_HANDLE hPMRExportHandle;
/*! The "key" to prove we have authorisation to use this PMR */
IMG_UINT64 uiPMRExportPassword;
/*! Size and alignment properties for this PMR. Note, these
numbers are not trusted in kernel, but we need to cache them
client-side in order to allocate from the VM arena. The kernel
will know the actual alignment and size of the PMR and thus
would prevent client code from breaching security here. Ditto
for physmem granularity (aka page size) if this is different
from alignment */
IMG_DEVMEM_SIZE_T uiSize;
/*! We call this "contiguity guarantee" to be more precise than
calling it "alignment" or "page size", terms which may seem
similar but have different emphasis. The number reported here
is the minimum contiguity guarantee from the creator of the
PMR. Now, there is no requirement to allocate that coarsely
from the RA. The alignment given to the RA simply needs to be
at least as coarse as the device page size for the heap we
ultimately intend to map into. What is important is that the
device MMU data page size is not greater than the minimum
contiguity guarantee from the PMR. This value is reported to
the client in order that it can choose to make early checks and
perhaps decide which heap (in a variable page size scenario) it
would be safe to map this PMR into. For convenience, the
client may choose to use this argument as the alignment of the
virtual range he chooses to allocate, but this is _not_
necessary and in many cases would be able to get away with a
finer alignment, should the heap into which this PMR will be
mapped support it. */
IMG_DEVMEM_LOG2ALIGN_T uiLog2ContiguityGuarantee;
} DEVMEM_EXPORTCOOKIE;
/* Enum that describes the operation associated with changing sparse memory */
typedef IMG_UINT32 SPARSE_MEM_RESIZE_FLAGS;
#define SPARSE_RESIZE_NONE 0U
/* This should be set to indicate the change needs allocation */
#define SPARSE_RESIZE_ALLOC 1U
/* This should be set to indicate the change needs free */
#define SPARSE_RESIZE_FREE 2U
#define SPARSE_RESIZE_BOTH (SPARSE_RESIZE_ALLOC | SPARSE_RESIZE_FREE)
/* To use with DevmemSubAllocate() as the default factor if no over-allocation
* is desired.
*/
#define DEVMEM_NO_PRE_ALLOCATE_MULTIPLIER (1U)
/* Defines the max length for PMR, MemDesc, Device memory History and RI debug
* annotations stored in memory, including the null terminator.
*/
#define DEVMEM_ANNOTATION_MAX_LEN ((IMG_UINT32)PVR_ANNOTATION_MAX_LEN + 1U)
/* Reserved VA space of a heap must always be multiple of DEVMEM_HEAP_RESERVED_SIZE_GRANULARITY
* Granularity has been chosen to support the max possible practically used OS page size.
*/
#define DEVMEM_HEAP_RESERVED_SIZE_GRANULARITY 0x10000 /* 64KB is MAX anticipated OS page size */
#endif /* #ifndef DEVICEMEM_TYPEDEFS_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,590 @@
/*************************************************************************/ /*!
@File
@Title Device Memory Management internal utility functions
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Utility functions used internally by device memory management
code.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef DEVICEMEM_UTILS_H
#define DEVICEMEM_UTILS_H
#include "devicemem.h"
#include "img_types.h"
#include "pvrsrv_error.h"
#include "pvr_debug.h"
#include "allocmem.h"
#include "ra.h"
#include "osfunc.h"
#include "lock.h"
#include "osmmap.h"
#include "pvrsrv_memallocflags_internal.h"
#define DEVMEM_HEAPNAME_MAXLENGTH 160
/*
* VA heap size should be at least OS page size. This check is validated in the DDK.
*/
#define DEVMEM_HEAP_MINIMUM_SIZE 0x10000 /* 64KB is MAX anticipated OS page size */
#if defined(DEVMEM_DEBUG) && defined(REFCOUNT_DEBUG)
#define DEVMEM_REFCOUNT_PRINT(fmt, ...) PVRSRVDebugPrintf(PVR_DBG_ERROR, __FILE__, __LINE__, fmt, __VA_ARGS__)
#else
#define DEVMEM_REFCOUNT_PRINT(fmt, ...)
#endif
/* If we need a reservation but we don't have a server-side reservation, we poison
* the entry with this value so that it's easily recognised in the debugger.
* Note that this is potentially a valid handle, but then so is NULL, which is
* no better, indeed worse, as it's not obvious in the debugger. The value
* doesn't matter. We _never_ use it (and because it's valid, we never assert
* it isn't this) but it's nice to have a value in the source code that we can
* grep for if things go wrong.
*/
#define LACK_OF_RESERVATION_POISON ((IMG_HANDLE)0x7117dead)
#define DEVICEMEM_HISTORY_ALLOC_INDEX_NONE 0xFFFFFFFF
struct DEVMEM_CONTEXT_TAG
{
SHARED_DEV_CONNECTION hDevConnection;
/* Number of heaps that have been created in this context
* (regardless of whether they have allocations)
*/
IMG_UINT32 uiNumHeaps;
/* Each "DEVMEM_CONTEXT" has a counterpart in the server, which
* is responsible for handling the mapping into device MMU.
* We have a handle to that here.
*/
IMG_HANDLE hDevMemServerContext;
/* Number of automagically created heaps in this context,
* i.e. those that are born at context creation time from the
* chosen "heap config" or "blueprint"
*/
IMG_UINT32 uiAutoHeapCount;
/* Pointer to array of such heaps */
struct DEVMEM_HEAP_TAG **ppsAutoHeapArray;
/* The cache line size for use when allocating memory,
* as it is not queryable on the client side
*/
IMG_UINT32 ui32CPUCacheLineSize;
/* Private data handle for device specific data */
IMG_HANDLE hPrivData;
};
/* Flags that record how a heaps virtual address space is managed. */
#define DEVMEM_HEAP_MANAGER_UNKNOWN 0
/* Heap VAs assigned by the client of Services APIs, heap's RA not used at all. */
#define DEVMEM_HEAP_MANAGER_USER (1U << 0)
/* Heap VAs managed by the OSs kernel, VA from CPU mapping call used */
#define DEVMEM_HEAP_MANAGER_KERNEL (1U << 1)
/* Heap VAs managed by the heap's own RA */
#define DEVMEM_HEAP_MANAGER_RA (1U << 2)
/* Heap VAs managed jointly by Services and the client of Services.
* The reserved region of the heap is managed explicitly by the client of Services
* The non-reserved region of the heap is managed by the heap's own RA */
#define DEVMEM_HEAP_MANAGER_DUAL_USER_RA (DEVMEM_HEAP_MANAGER_USER | DEVMEM_HEAP_MANAGER_RA)
struct DEVMEM_HEAP_TAG
{
/* Name of heap - for debug and lookup purposes. */
IMG_CHAR *pszName;
/* Number of live imports in the heap */
ATOMIC_T hImportCount;
/* Base address and size of heap, required by clients due to some
* requesters not being full range
*/
IMG_DEV_VIRTADDR sBaseAddress;
DEVMEM_SIZE_T uiSize;
/* The process' malloc heap may have a higher minimum address than our base.
* In this case we will allocate RA resources to pad the SVM heap's base address
* until it is possible to map.
*
* These values are used to keep track of the RA allocations made, in order
* to free them before the SVM RA is destroyed.
*/
IMG_UINT32 ui32SVMBasePaddingCount; /* The number of allocations made for padding. */
DEVMEM_SIZE_T uiSVMBasePaddingSize; /* The size of the allocations made for padding. */
DEVMEM_SIZE_T uiReservedRegionSize; /* uiReservedRegionLength in DEVMEM_HEAP_BLUEPRINT */
/* The heap manager, describing if the space is managed by the user, an RA,
* kernel or combination */
IMG_UINT32 ui32HeapManagerFlags;
/* This RA is for managing sub-allocations within the imports (PMRs)
* within the heap's virtual space. RA only used in DevmemSubAllocate()
* to track sub-allocated buffers.
*
* Resource Span - a PMR import added when the RA calls the
* imp_alloc CB (SubAllocImportAlloc) which returns the
* PMR import and size (span length).
* Resource - an allocation/buffer i.e. a MemDesc. Resource size represents
* the size of the sub-allocation.
*/
RA_ARENA *psSubAllocRA;
IMG_CHAR *pszSubAllocRAName;
/* The psQuantizedVMRA is for the coarse allocation (PMRs) of virtual
* space from the heap.
*
* Resource Span - the heap's VM space from base to base+length,
* only one is added at heap creation.
* Resource - a PMR import associated with the heap. Dynamic number
* as memory is allocated/freed from or mapped/unmapped to
* the heap. Resource size follows PMR logical size.
*/
RA_ARENA *psQuantizedVMRA;
IMG_CHAR *pszQuantizedVMRAName;
/* We also need to store a copy of the quantum size in order to feed
* this down to the server.
*/
IMG_UINT32 uiLog2Quantum;
/* Store a copy of the minimum import alignment */
IMG_UINT32 uiLog2ImportAlignment;
/* The parent memory context for this heap */
struct DEVMEM_CONTEXT_TAG *psCtx;
/* Lock to protect this structure */
POS_LOCK hLock;
/* Each "DEVMEM_HEAP" has a counterpart in the server, which is
* responsible for handling the mapping into device MMU.
* We have a handle to that here.
*/
IMG_HANDLE hDevMemServerHeap;
/* This heap is fully allocated and premapped into the device address space.
* Used in virtualisation for firmware heaps of Guest and optionally Host
* drivers. */
IMG_BOOL bPremapped;
};
typedef IMG_UINT32 DEVMEM_PROPERTIES_T; /*!< Typedef for Devicemem properties */
#define DEVMEM_PROPERTIES_EXPORTABLE (1UL<<0) /*!< Is it exportable? */
#define DEVMEM_PROPERTIES_IMPORTED (1UL<<1) /*!< Is it imported from another process? */
#define DEVMEM_PROPERTIES_SUBALLOCATABLE (1UL<<2) /*!< Is it suballocatable? */
#define DEVMEM_PROPERTIES_IMPORT_IS_ZEROED (1UL<<4) /*!< Is the memory fully zeroed? */
#define DEVMEM_PROPERTIES_IMPORT_IS_CLEAN (1UL<<5) /*!< Is the memory clean, i.e. not been used before? */
#define DEVMEM_PROPERTIES_SECURE (1UL<<6) /*!< Is it a special secure buffer? No CPU maps allowed! */
#define DEVMEM_PROPERTIES_IMPORT_IS_POISONED (1UL<<7) /*!< Is the memory fully poisoned? */
#define DEVMEM_PROPERTIES_NO_CPU_MAPPING (1UL<<8) /* No CPU Mapping is allowed, RW attributes
are further derived from allocation memory flags */
#define DEVMEM_PROPERTIES_NO_LAYOUT_CHANGE (1UL<<9) /* No sparse resizing allowed, once a memory
layout is chosen, no change allowed later */
typedef struct DEVMEM_DEVICE_IMPORT_TAG
{
DEVMEM_HEAP *psHeap; /*!< Heap this import is bound to */
IMG_DEV_VIRTADDR sDevVAddr; /*!< Device virtual address of the import */
IMG_UINT32 ui32RefCount; /*!< Refcount of the device virtual address */
IMG_HANDLE hReservation; /*!< Device memory reservation handle */
IMG_BOOL bMapped; /*!< This is import mapped? */
POS_LOCK hLock; /*!< Lock to protect the device import */
} DEVMEM_DEVICE_IMPORT;
typedef struct DEVMEM_CPU_IMPORT_TAG
{
void *pvCPUVAddr; /*!< CPU virtual address of the import */
IMG_UINT32 ui32RefCount; /*!< Refcount of the CPU virtual address */
IMG_HANDLE hOSMMapData; /*!< CPU mapping handle */
POS_LOCK hLock; /*!< Lock to protect the CPU import */
} DEVMEM_CPU_IMPORT;
typedef struct DEVMEM_IMPORT_TAG
{
SHARED_DEV_CONNECTION hDevConnection;
IMG_DEVMEM_ALIGN_T uiAlign; /*!< Alignment of the PMR */
DEVMEM_SIZE_T uiSize; /*!< Size of import */
ATOMIC_T hRefCount; /*!< Refcount for this import */
DEVMEM_PROPERTIES_T uiProperties; /*!< Stores properties of an import like if
it is exportable, pinned or suballocatable */
IMG_HANDLE hPMR; /*!< Handle to the PMR */
PVRSRV_MEMALLOCFLAGS_T uiFlags; /*!< Flags for this import */
POS_LOCK hLock; /*!< Lock to protect the import */
DEVMEM_DEVICE_IMPORT sDeviceImport; /*!< Device specifics of the import */
DEVMEM_CPU_IMPORT sCPUImport; /*!< CPU specifics of the import */
} DEVMEM_IMPORT;
typedef struct DEVMEM_DEVICE_MEMDESC_TAG
{
IMG_DEV_VIRTADDR sDevVAddr; /*!< Device virtual address of the allocation */
IMG_UINT32 ui32RefCount; /*!< Refcount of the device virtual address */
POS_LOCK hLock; /*!< Lock to protect device memdesc */
} DEVMEM_DEVICE_MEMDESC;
typedef struct DEVMEM_CPU_MEMDESC_TAG
{
void *pvCPUVAddr; /*!< CPU virtual address of the import */
IMG_UINT32 ui32RefCount; /*!< Refcount of the device CPU address */
POS_LOCK hLock; /*!< Lock to protect CPU memdesc */
} DEVMEM_CPU_MEMDESC;
struct DEVMEM_MEMDESC_TAG
{
DEVMEM_IMPORT *psImport; /*!< Import this memdesc is on */
IMG_DEVMEM_OFFSET_T uiOffset; /*!< Offset into import where our allocation starts */
IMG_DEVMEM_SIZE_T uiAllocSize; /*!< Size of the allocation */
ATOMIC_T hRefCount; /*!< Refcount of the memdesc */
POS_LOCK hLock; /*!< Lock to protect memdesc */
IMG_HANDLE hPrivData;
DEVMEM_DEVICE_MEMDESC sDeviceMemDesc; /*!< Device specifics of the memdesc */
DEVMEM_CPU_MEMDESC sCPUMemDesc; /*!< CPU specifics of the memdesc */
IMG_CHAR szText[DEVMEM_ANNOTATION_MAX_LEN]; /*!< Annotation for this memdesc */
IMG_UINT32 ui32AllocationIndex;
#if defined(DEBUG)
IMG_BOOL bPoisonOnFree;
#endif
#if defined(PVRSRV_ENABLE_GPU_MEMORY_INFO)
IMG_HANDLE hRIHandle; /*!< Handle to RI information */
#endif
};
/* The physical descriptor used to store handles and information of device
* physical allocations.
*/
struct DEVMEMX_PHYS_MEMDESC_TAG
{
IMG_UINT32 uiNumPages; /*!< Number of pages that the import has*/
IMG_UINT32 uiLog2PageSize; /*!< Page size */
ATOMIC_T hRefCount; /*!< Refcount of the memdesc */
PVRSRV_MEMALLOCFLAGS_T uiFlags; /*!< Flags for this import */
IMG_HANDLE hPMR; /*!< Handle to the PMR */
DEVMEM_CPU_IMPORT sCPUImport; /*!< CPU specifics of the memdesc */
SHARED_DEV_CONNECTION hConnection; /*!< Services connection for the server */
void *pvUserData; /*!< User data */
};
/* The virtual descriptor used to store handles and information of a device
* virtual range and the mappings to it.
*/
struct DEVMEMX_VIRT_MEMDESC_TAG
{
IMG_UINT32 uiNumPages; /*!< Number of pages that the import has*/
PVRSRV_MEMALLOCFLAGS_T uiFlags; /*!< Flags for this import */
DEVMEMX_PHYSDESC **apsPhysDescTable; /*!< Table to store links to physical descs */
DEVMEM_DEVICE_IMPORT sDeviceImport; /*!< Device specifics of the memdesc */
IMG_CHAR szText[DEVMEM_ANNOTATION_MAX_LEN]; /*!< Annotation for this virt memdesc */
IMG_UINT32 ui32AllocationIndex; /*!< To track mappings in this range */
#if defined(PVRSRV_ENABLE_GPU_MEMORY_INFO)
IMG_HANDLE hRIHandle; /*!< Handle to RI information */
#endif
};
#define DEVICEMEM_UTILS_NO_ADDRESS 0
/******************************************************************************
@Function DevmemValidateParams
@Description Check if flags are conflicting and if align is a size multiple.
@Input uiSize Size of the import.
@Input uiAlign Alignment of the import.
@Input puiFlags Pointer to the flags for the import.
@return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR DevmemValidateParams(IMG_DEVMEM_SIZE_T uiSize,
IMG_DEVMEM_ALIGN_T uiAlign,
PVRSRV_MEMALLOCFLAGS_T *puiFlags);
/******************************************************************************
@Function DevmemImportStructAlloc
@Description Allocates memory for an import struct. Does not allocate a PMR!
Create locks for CPU and Devmem mappings.
@Input hDevConnection Connection to use for calls from the import.
@Input ppsImport The import to allocate.
@return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR DevmemImportStructAlloc(SHARED_DEV_CONNECTION hDevConnection,
DEVMEM_IMPORT **ppsImport);
/******************************************************************************
@Function DevmemImportStructInit
@Description Initialises the import struct with the given parameters.
Set it's refcount to 1!
@Input psImport The import to initialise.
@Input uiSize Size of the import.
@Input uiAlign Alignment of allocations in the import.
@Input uiMapFlags
@Input hPMR Reference to the PMR of this import struct.
@Input uiProperties Properties of the import. Is it exportable,
imported, suballocatable?
******************************************************************************/
void DevmemImportStructInit(DEVMEM_IMPORT *psImport,
IMG_DEVMEM_SIZE_T uiSize,
IMG_DEVMEM_ALIGN_T uiAlign,
PVRSRV_MEMALLOCFLAGS_T uiMapFlags,
IMG_HANDLE hPMR,
DEVMEM_PROPERTIES_T uiProperties);
/******************************************************************************
@Function DevmemImportStructDevMap
@Description NEVER call after the last DevmemMemDescRelease()
Maps the PMR referenced by the import struct to the device's
virtual address space.
Does nothing but increase the cpu mapping refcount if the
import struct was already mapped.
@Input psHeap The heap to map to.
@Input bMap Caller can choose if the import should be really
mapped in the page tables or if just a virtual range
should be reserved and the refcounts increased.
@Input psImport The import we want to map.
@Input uiOptionalMapAddress An optional address to map to.
Pass DEVICEMEM_UTILS_NOADDRESS if not used.
@return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR DevmemImportStructDevMap(DEVMEM_HEAP *psHeap,
IMG_BOOL bMap,
DEVMEM_IMPORT *psImport,
IMG_UINT64 uiOptionalMapAddress);
/******************************************************************************
@Function DevmemImportStructDevUnmap
@Description Unmaps the PMR referenced by the import struct from the
device's virtual address space.
If this was not the last remaining CPU mapping on the import
struct only the cpu mapping refcount is decreased.
@return A boolean to signify if the import was unmapped.
******************************************************************************/
IMG_BOOL DevmemImportStructDevUnmap(DEVMEM_IMPORT *psImport);
/******************************************************************************
@Function DevmemImportStructCPUMap
@Description NEVER call after the last DevmemMemDescRelease()
Maps the PMR referenced by the import struct to the CPU's
virtual address space.
Does nothing but increase the cpu mapping refcount if the
import struct was already mapped.
@return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR DevmemImportStructCPUMap(DEVMEM_IMPORT *psImport);
/******************************************************************************
@Function DevmemImportStructCPUUnmap
@Description Unmaps the PMR referenced by the import struct from the CPU's
virtual address space.
If this was not the last remaining CPU mapping on the import
struct only the cpu mapping refcount is decreased.
******************************************************************************/
void DevmemImportStructCPUUnmap(DEVMEM_IMPORT *psImport);
/******************************************************************************
@Function DevmemImportStructAcquire
@Description Acquire an import struct by increasing it's refcount.
******************************************************************************/
void DevmemImportStructAcquire(DEVMEM_IMPORT *psImport);
/******************************************************************************
@Function DevmemImportStructRelease
@Description Reduces the refcount of the import struct.
Destroys the import in the case it was the last reference.
Destroys underlying PMR if this import was the last reference
to it.
@return A boolean to signal if the import was destroyed. True = yes.
******************************************************************************/
IMG_BOOL DevmemImportStructRelease(DEVMEM_IMPORT *psImport);
/******************************************************************************
@Function DevmemImportDiscard
@Description Discard a created, but uninitialised import structure.
This must only be called before DevmemImportStructInit
after which DevmemImportStructRelease must be used to
"free" the import structure.
******************************************************************************/
void DevmemImportDiscard(DEVMEM_IMPORT *psImport);
/******************************************************************************
@Function DevmemMemDescAlloc
@Description Allocates a MemDesc and create it's various locks.
Zero the allocated memory.
@return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR DevmemMemDescAlloc(DEVMEM_MEMDESC **ppsMemDesc);
#if defined(DEBUG)
/******************************************************************************
@Function DevmemMemDescSetPoF
@Description Sets the Poison on Free flag to true for this MemDesc if the
given MemAllocFlags have the Poison on Free bit set.
Poison on Free is a debug only feature.
******************************************************************************/
void DevmemMemDescSetPoF(DEVMEM_MEMDESC *psMemDesc, PVRSRV_MEMALLOCFLAGS_T uiFlags);
#endif
/******************************************************************************
@Function DevmemMemDescInit
@Description Sets the given offset and import struct fields in the MemDesc.
Initialises refcount to 1 and other values to 0.
@Input psMemDesc MemDesc to initialise.
@Input uiOffset Offset in the import structure.
@Input psImport Import the MemDesc is on.
@Input uiAllocSize Size of the allocation
******************************************************************************/
void DevmemMemDescInit(DEVMEM_MEMDESC *psMemDesc,
IMG_DEVMEM_OFFSET_T uiOffset,
DEVMEM_IMPORT *psImport,
IMG_DEVMEM_SIZE_T uiAllocSize);
/******************************************************************************
@Function DevmemMemDescAcquire
@Description Acquires the MemDesc by increasing it's refcount.
******************************************************************************/
void DevmemMemDescAcquire(DEVMEM_MEMDESC *psMemDesc);
/******************************************************************************
@Function DevmemMemDescRelease
@Description Releases the MemDesc by reducing it's refcount.
Destroy the MemDesc if it's recount is 0.
Destroy the import struct the MemDesc is on if that was the
last MemDesc on the import, probably following the destruction
of the underlying PMR.
@return A boolean to signal if the MemDesc was destroyed. True = yes.
******************************************************************************/
IMG_BOOL DevmemMemDescRelease(DEVMEM_MEMDESC *psMemDesc);
/******************************************************************************
@Function DevmemMemDescDiscard
@Description Discard a created, but uninitialised MemDesc structure.
This must only be called before DevmemMemDescInit after
which DevmemMemDescRelease must be used to "free" the
MemDesc structure.
******************************************************************************/
void DevmemMemDescDiscard(DEVMEM_MEMDESC *psMemDesc);
/******************************************************************************
@Function GetImportProperties
@Description Atomically read psImport->uiProperties
It's possible that another thread modifies uiProperties
immediately after this function returns, making its result
stale. So, it's recommended to use this function only to
check if certain non-volatile flags were set.
******************************************************************************/
static INLINE DEVMEM_PROPERTIES_T GetImportProperties(DEVMEM_IMPORT *psImport)
{
DEVMEM_PROPERTIES_T uiProperties;
OSLockAcquire(psImport->hLock);
uiProperties = psImport->uiProperties;
OSLockRelease(psImport->hLock);
return uiProperties;
}
/******************************************************************************
@Function DevmemCPUMemSet
@Description Given a CPU Mapped Devmem address, set the memory at that
range (address, address + size) to the uiPattern provided.
Flags determine the OS abstracted MemSet method to use.
******************************************************************************/
static INLINE void DevmemCPUMemSet(void *pvMem,
IMG_UINT8 uiPattern,
IMG_DEVMEM_SIZE_T uiSize,
PVRSRV_MEMALLOCFLAGS_T uiFlags)
{
if (PVRSRV_CHECK_CPU_UNCACHED(uiFlags))
{
OSDeviceMemSet(pvMem, uiPattern, uiSize);
}
else
{
/* it's safe to use OSCachedMemSet() for cached and wc memory */
OSCachedMemSet(pvMem, uiPattern, uiSize);
}
}
/******************************************************************************
@Function DevmemCPUMapCheckImportProperties
@Description Given a MemDesc check that the import properties are correct
to allow for mapping the MemDesc to the CPU.
Returns PVRSRV_OK on success.
******************************************************************************/
static INLINE PVRSRV_ERROR DevmemCPUMapCheckImportProperties(DEVMEM_MEMDESC *psMemDesc)
{
DEVMEM_PROPERTIES_T uiProperties = GetImportProperties(psMemDesc->psImport);
#if defined(SUPPORT_SECURITY_VALIDATION)
if (uiProperties & DEVMEM_PROPERTIES_SECURE)
{
PVR_DPF((PVR_DBG_WARNING,
"%s: Allocation is a secure buffer. "
"It should not be possible to map to CPU, but for security "
"validation this will be allowed for testing purposes, "
"as long as the buffer is pinned.",
__func__));
}
#endif
if (uiProperties & DEVMEM_PROPERTIES_NO_CPU_MAPPING)
{
PVR_DPF((PVR_DBG_ERROR,
"%s: CPU Mapping is not possible on this allocation!",
__func__));
return PVRSRV_ERROR_INVALID_MAP_REQUEST;
}
return PVRSRV_OK;
}
#endif /* DEVICEMEM_UTILS_H */

View File

@@ -0,0 +1,236 @@
/*************************************************************************/ /*!
@File
@Title Common types for Debug Info framework.
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef DI_COMMON_H
#define DI_COMMON_H
#include "img_types.h"
/* Token that signals that a header should be printed. */
#define DI_START_TOKEN ((void *) 1)
/* This is a public handle to an entry. */
#ifndef DI_GROUP_DEFINED
#define DI_GROUP_DEFINED
typedef struct DI_GROUP DI_GROUP;
#endif
#ifndef DI_ENTRY_DEFINED
#define DI_ENTRY_DEFINED
typedef struct DI_ENTRY DI_ENTRY;
#endif
typedef struct OSDI_IMPL_ENTRY OSDI_IMPL_ENTRY;
/*! Debug Info entries types. */
typedef enum DI_ENTRY_TYPE
{
DI_ENTRY_TYPE_GENERIC, /*!< generic entry type, implements
start/stop/next/show iterator
interface */
DI_ENTRY_TYPE_RANDOM_ACCESS, /*!< random access entry, implements
seek/read iterator interface */
} DI_ENTRY_TYPE;
/*! @Function DI_PFN_START
*
* @Description
* Start operation returns first entry and passes it to Show operation.
*
* @Input psEntry pointer to the implementation entry
* @InOut pui64Pos current data position in the entry
*
* @Return pointer to data that will be passed to the other iterator
* functions in pvData argument
*/
typedef void *(*DI_PFN_START)(OSDI_IMPL_ENTRY *psEntry, IMG_UINT64 *pui64Pos);
/*! @Function DI_PFN_STOP
*
* @Description
* Stop operations is called after iterator reaches end of data.
*
* If pvData was allocated in pfnStart it should be freed here.
*
* @Input psEntry pointer to the implementation entry
* @Input pvData pointer to data returned from pfnStart/pfnNext
*/
typedef void (*DI_PFN_STOP)(OSDI_IMPL_ENTRY *psEntry, void *pvData);
/*! @Function DI_PFN_NEXT
*
* @Description
* Next returns next data entry and passes it to Show operation.
*
* @Input psEntry pointer to the implementation entry
* @Input pvData pointer to data returned from pfnStart/pfnNext
* @InOut pui64Pos current data position in the entry
*/
typedef void *(*DI_PFN_NEXT)(OSDI_IMPL_ENTRY *psEntry, void *pvData,
IMG_UINT64 *pui64Pos);
/*! @Function DI_PFN_SHOW
*
* @Description
* Outputs the data element.
*
* @Input psEntry pointer to the implementation entry
* @Input pvData pointer to data returned from pfnStart/pfnNext
*/
typedef int (*DI_PFN_SHOW)(OSDI_IMPL_ENTRY *psEntry, void *pvData);
/*! @Function DI_PFN_SEEK
*
* @Description
* Changes position of the entry data pointer
*
* @Input uiOffset new entry offset (absolute)
* @Input pvData private data provided during entry creation
*/
typedef IMG_INT64 (*DI_PFN_SEEK)(IMG_UINT64 ui64Offset, void *pvData);
/*! @Function DI_PFN_READ
*
* @Description
* Retrieves data from the entry from position previously set by Seek.
*
* @Input pszBuffer output buffer
* @Input ui64Count length of the output buffer
* @InOut pui64Pos pointer to the current position in the entry
* @Input pvData private data provided during entry creation
*/
typedef IMG_INT64 (*DI_PFN_READ)(IMG_CHAR *pszBuffer, IMG_UINT64 ui64Count,
IMG_UINT64 *pui64Pos, void *pvData);
/*! @Function DI_PFN_WRITE
*
* @Description
* Handle writes operation to the entry.
*
* @Input pszBuffer NUL-terminated buffer containing written data
* @Input ui64Count length of the data in pszBuffer (length of the buffer)
* @InOut pui64Pos pointer to the current position in the entry
* @Input pvData private data provided during entry creation
*/
typedef IMG_INT64 (*DI_PFN_WRITE)(const IMG_CHAR *pszBuffer,
IMG_UINT64 ui64Count, IMG_UINT64 *pui64Pos,
void *pvData);
/*! Debug info entry iterator.
*
* This covers all entry types: GENERIC and RANDOM_ACCESS.
*
* The GENERIC entry type
*
* The GENERIC type should implement either a full set of following callbacks:
* pfnStart, pfnStop, pfnNext and pfnShow, or pfnShow only. If only pfnShow
* callback is given the framework will use default handlers in place of the
* other ones.
*
* e.g. for generic entry:
*
* struct sIter = {
* .pfnStart = StartCb, .pfnStop = StopCb, pfnNext = NextCb,
* .pfnShow = ShowCb
* };
*
* The use case for implementing pfnShow only is if the data for the given
* entry is short and can be printed in one go because the pfnShow callback
* will be called only once.
*
* e.g. for one-shot print generic entry:
*
* struct sIter = {
* .pfnShow = SingleShowCb
* };
*
* The DICreateEntry() function will return error if DI_ENTRY_TYPE_GENERIC
* type is used and invalid combination of callbacks is given.
*
* The RANDOM_ACCESS entry
*
* The RANDOM_ACCESS type should implement either both pfnSeek and pfnRead
* or pfnRead only callbacks.
*
* e.g. of seekable and readable random access entry:
*
* struct sIter = {
* .pfnSeek = SeekCb, .pfnRead = ReadCb
* };
*
* The DICreateEntry() function will return error if DI_ENTRY_TYPE_RANDOM_ACCESS
* type is used and invalid combination of callbacks is given.
*
* Writing to file (optional)
*
* The iterator allows also to pass a pfnWrite callback that allows implementing
* write operation on the entry. The write operation is entry type agnostic
* which means that it can be defined for both GENERIC and RANDOM_ACCESS
* entries.
*
* e.g. for writable one-shot print generic entry
*
* struct sIter = {
* .pfnShow = SingleShowCb, .pfnWrite = WriteCb
* };
*/
typedef struct DI_ITERATOR_CB
{
/* Generic entry interface. */
DI_PFN_START pfnStart; /*!< Starts iteration and returns first element
of entry's data. */
DI_PFN_STOP pfnStop; /*!< Stops iteration. */
DI_PFN_NEXT pfnNext; /*!< Returns next element of entry's data. */
DI_PFN_SHOW pfnShow; /*!< Shows current data element of an entry. */
/* Optional random access entry interface. */
DI_PFN_SEEK pfnSeek; /*!< Sets data pointer in an entry. */
DI_PFN_READ pfnRead; /*!< Reads data from an entry. */
/* Optional writing to entry interface. Null terminated. */
DI_PFN_WRITE pfnWrite; /*!< Performs write operation on an entry. */
IMG_UINT32 ui32WriteLenMax; /*!< Maximum char length of entry
accepted for write. Includes \0 */
} DI_ITERATOR_CB;
#endif /* DI_COMMON_H */

View File

@@ -0,0 +1,881 @@
/*************************************************************************/ /*!
@File
@Title OS agnostic implementation of Debug Info interface.
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Implements osdi_impl.h API to provide access to driver's
debug data via pvrdebug.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#include "allocmem.h"
#include "hash.h"
#include "hash_functions.h"
#include "img_defs.h"
#include "img_types.h"
#include "lock.h"
#include "osfunc_common.h"
#include "osfunc.h" /* for thread */
#include "tlstream.h"
#include "dllist.h"
#include "osdi_impl.h"
#include "di_impl_brg.h"
#include "di_impl_brg_intern.h"
#include "pvr_dicommon.h"
#if defined(PVRSRV_FORCE_UNLOAD_IF_BAD_STATE)
#include "pvrsrv.h"
#endif
#define ENTRIES_TABLE_INIT_SIZE 64
#define STREAM_BUFFER_SIZE 0x4000 /* 16KB */
#define STREAM_LINE_LENGTH 512
#if defined(PVRSRV_SERVER_THREADS_INDEFINITE_SLEEP)
#define WRITER_THREAD_SLEEP_TIMEOUT 0ULL
#else
#define WRITER_THREAD_SLEEP_TIMEOUT 28800000000ULL
#endif
#define WRITER_THREAD_DESTROY_TIMEOUT 100000ULL
#define WRITER_THREAD_DESTROY_RETRIES 10U
#define WRITE_RETRY_COUNT 10 /* retry a write to a TL buffer 10 times */
#define WRITE_RETRY_WAIT_TIME 100 /* wait 10ms between write retries */
typedef enum THREAD_STATE
{
THREAD_STATE_NULL,
THREAD_STATE_ALIVE,
THREAD_STATE_TERMINATED,
} THREAD_STATE;
static struct DIIB_IMPL
{
HASH_TABLE *psEntriesTable; /*!< Table of entries. */
POSWR_LOCK psEntriesLock; /*!< Protects psEntriesTable. */
IMG_HANDLE hWriterThread;
IMG_HANDLE hWriterEventObject;
ATOMIC_T eThreadState;
DLLIST_NODE sWriterQueue;
POS_LOCK psWriterLock; /*!< Protects sWriterQueue. */
} *_g_psImpl;
struct DIIB_GROUP
{
const IMG_CHAR *pszName;
struct DIIB_GROUP *psParentGroup;
};
struct DIIB_ENTRY
{
struct DIIB_GROUP *psParentGroup;
OSDI_IMPL_ENTRY sImplEntry;
DI_ITERATOR_CB sIterCb;
DI_ENTRY_TYPE eType;
IMG_CHAR pszFullPath[DI_IMPL_BRG_PATH_LEN];
void *pvPrivData;
POS_LOCK hLock; /*!< Protects access to entry's iterator. */
};
struct DI_CONTEXT_TAG
{
IMG_HANDLE hStream;
ATOMIC_T iRefCnt;
IMG_BOOL bClientConnected; /*!< Indicated that the client is or is not
connected to the DI. */
};
struct DIIB_WORK_ITEM
{
DI_CONTEXT *psContext;
DIIB_ENTRY *psEntry;
IMG_UINT64 ui64Size;
IMG_UINT64 ui64Offset;
DLLIST_NODE sQueueElement;
};
/* ----- native callbacks interface ----------------------------------------- */
static void _WriteWithRetires(void *pvNativeHandle, const IMG_CHAR *pszStr,
IMG_UINT uiLen)
{
PVRSRV_ERROR eError;
IMG_INT iRetry = 0;
IMG_UINT32 ui32Flags = TL_FLAG_NO_WRITE_FAILED;
do
{
/* Try to write to the buffer but don't inject MOST_RECENT_WRITE_FAILED
* packet in case of failure because we're going to retry. */
eError = TLStreamWriteRetFlags(pvNativeHandle, (IMG_UINT8 *) pszStr,
uiLen, &ui32Flags);
if (eError == PVRSRV_ERROR_STREAM_FULL)
{
// wait to give the client a change to read
OSSleepms(WRITE_RETRY_WAIT_TIME);
}
}
while (eError == PVRSRV_ERROR_STREAM_FULL && iRetry++ < WRITE_RETRY_COUNT);
/* One last try to write to the buffer. In this case upon failure
* a MOST_RECENT_WRITE_FAILED packet will be inject to the buffer to
* indicate data loss. */
if (eError == PVRSRV_ERROR_STREAM_FULL)
{
eError = TLStreamWrite(pvNativeHandle, (IMG_UINT8 *) pszStr, uiLen);
}
PVR_LOG_IF_ERROR(eError, "TLStreamWrite");
}
static void _WriteData(void *pvNativeHandle, const void *pvData,
IMG_UINT32 uiSize)
{
_WriteWithRetires(pvNativeHandle, pvData, uiSize);
}
__printf(2, 0)
static void _VPrintf(void *pvNativeHandle, const IMG_CHAR *pszFmt,
va_list pArgs)
{
IMG_CHAR pcBuffer[STREAM_LINE_LENGTH];
IMG_UINT uiLen = OSVSNPrintf(pcBuffer, sizeof(pcBuffer) - 1, pszFmt, pArgs);
pcBuffer[uiLen] = '\0';
_WriteWithRetires(pvNativeHandle, pcBuffer, uiLen + 1);
}
static void _Puts(void *pvNativeHandle, const IMG_CHAR *pszStr)
{
_WriteWithRetires(pvNativeHandle, pszStr, OSStringLength(pszStr) + 1);
}
static IMG_BOOL _HasOverflowed(void *pvNativeHandle)
{
PVR_UNREFERENCED_PARAMETER(pvNativeHandle);
return IMG_FALSE;
}
static OSDI_IMPL_ENTRY_CB _g_sEntryCallbacks = {
.pfnWrite = _WriteData,
.pfnVPrintf = _VPrintf,
.pfnPuts = _Puts,
.pfnHasOverflowed = _HasOverflowed,
};
/* ----- entry operations --------------------------------------------------- */
static PVRSRV_ERROR _ContextUnrefAndMaybeDestroy(DI_CONTEXT *psContext)
{
if (OSAtomicDecrement(&psContext->iRefCnt) == 0)
{
TLStreamClose(psContext->hStream);
OSFreeMem(psContext);
}
return PVRSRV_OK;
}
static IMG_INT64 _ReadGeneric(const DI_CONTEXT *psContext, DIIB_ENTRY *psEntry)
{
IMG_INT64 iRet = 0;
IMG_UINT64 ui64Pos = 0;
DI_ITERATOR_CB *psIter = &psEntry->sIterCb;
OSDI_IMPL_ENTRY *psImplEntry = &psEntry->sImplEntry;
PVRSRV_ERROR eError;
if (psIter->pfnStart != NULL)
{
/* this is a full sequence of the operation */
void *pvData = psIter->pfnStart(psImplEntry, &ui64Pos);
while (pvData != NULL && psContext->bClientConnected)
{
iRet = psIter->pfnShow(psImplEntry, pvData);
if (iRet < 0)
{
break;
}
pvData = psIter->pfnNext(psImplEntry, pvData, &ui64Pos);
}
psIter->pfnStop(psImplEntry, pvData);
}
else if (psIter->pfnShow != NULL)
{
/* this is a simplified sequence of the operation */
iRet = psIter->pfnShow(psImplEntry, NULL);
}
eError = TLStreamMarkEOS(psImplEntry->pvNative, IMG_FALSE);
PVR_LOG_GOTO_IF_ERROR(eError, "TLStreamMarkEOS", return_error_);
return iRet;
return_error_:
return -1;
}
static IMG_INT64 _ReadRndAccess(DIIB_ENTRY *psEntry, IMG_UINT64 ui64Count,
IMG_UINT64 *pui64Pos, void *pvData)
{
PVRSRV_ERROR eError;
IMG_UINT8 *pui8Buffer;
IMG_HANDLE hStream = psEntry->sImplEntry.pvNative;
if (psEntry->sIterCb.pfnRead == NULL)
{
return -1;
}
eError = TLStreamReserve(hStream, &pui8Buffer, ui64Count);
PVR_LOG_GOTO_IF_ERROR(eError, "TLStreamReserve", return_error_);
psEntry->sIterCb.pfnRead((IMG_CHAR *) pui8Buffer, ui64Count, pui64Pos,
pvData);
eError = TLStreamCommit(hStream, ui64Count);
PVR_LOG_GOTO_IF_ERROR(eError, "TLStreamCommit", return_error_);
eError = TLStreamMarkEOS(psEntry->sImplEntry.pvNative, IMG_FALSE);
PVR_LOG_GOTO_IF_ERROR(eError, "TLStreamMarkEOS", return_error_);
return 0;
return_error_:
return -1;
}
static void _WriterThread(void *pvArg)
{
PVRSRV_ERROR eError;
IMG_HANDLE hEvent;
DLLIST_NODE *psNode;
PVR_UNREFERENCED_PARAMETER(pvArg);
eError = OSEventObjectOpen(_g_psImpl->hWriterEventObject, &hEvent);
PVR_LOG_RETURN_VOID_IF_ERROR(eError, "OSEventObjectOpen");
#ifdef PVRSRV_FORCE_UNLOAD_IF_BAD_STATE
while (PVRSRVGetPVRSRVData()->eServicesState == PVRSRV_SERVICES_STATE_OK &&
OSAtomicRead(&_g_psImpl->eThreadState) == THREAD_STATE_ALIVE)
#else
while (OSAtomicRead(&_g_psImpl->eThreadState) == THREAD_STATE_ALIVE)
#endif
{
struct DIIB_WORK_ITEM *psItem = NULL;
OSLockAcquire(_g_psImpl->psWriterLock);
/* Get element from list tail so that we always get the oldest element
* (elements are added to head). */
while ((psNode = dllist_get_prev_node(&_g_psImpl->sWriterQueue)) != NULL)
{
IMG_INT64 i64Ret;
DIIB_ENTRY *psEntry;
OSDI_IMPL_ENTRY *psImplEntry;
dllist_remove_node(psNode);
OSLockRelease(_g_psImpl->psWriterLock);
psItem = IMG_CONTAINER_OF(psNode, struct DIIB_WORK_ITEM,
sQueueElement);
psEntry = psItem->psEntry;
psImplEntry = &psItem->psEntry->sImplEntry;
/* if client has already disconnected we can just drop this item */
if (psItem->psContext->bClientConnected)
{
PVR_ASSERT(psItem->psContext->hStream != NULL);
psImplEntry->pvNative = psItem->psContext->hStream;
if (psEntry->eType == DI_ENTRY_TYPE_GENERIC)
{
i64Ret = _ReadGeneric(psItem->psContext, psEntry);
PVR_LOG_IF_FALSE(i64Ret >= 0, "generic access read operation "
"failed");
}
else if (psEntry->eType == DI_ENTRY_TYPE_RANDOM_ACCESS)
{
IMG_UINT64 ui64Pos = psItem->ui64Offset;
i64Ret = _ReadRndAccess(psEntry, psItem->ui64Size, &ui64Pos,
psEntry->pvPrivData);
PVR_LOG_IF_FALSE(i64Ret >= 0, "random access read operation "
"failed");
}
else
{
PVR_ASSERT(psEntry->eType == DI_ENTRY_TYPE_GENERIC ||
psEntry->eType == DI_ENTRY_TYPE_RANDOM_ACCESS);
}
psImplEntry->pvNative = NULL;
}
else
{
PVR_DPF((PVR_DBG_MESSAGE, "client reading entry \"%s\" has "
"disconnected", psEntry->pszFullPath));
}
_ContextUnrefAndMaybeDestroy(psItem->psContext);
OSFreeMemNoStats(psItem);
OSLockAcquire(_g_psImpl->psWriterLock);
}
OSLockRelease(_g_psImpl->psWriterLock);
eError = OSEventObjectWaitKernel(hEvent, WRITER_THREAD_SLEEP_TIMEOUT);
if (eError != PVRSRV_OK && eError != PVRSRV_ERROR_TIMEOUT)
{
PVR_LOG_ERROR(eError, "OSEventObjectWaitKernel");
}
}
OSLockAcquire(_g_psImpl->psWriterLock);
/* clear the queue if there are any items pending */
while ((psNode = dllist_get_prev_node(&_g_psImpl->sWriterQueue)) != NULL)
{
struct DIIB_WORK_ITEM *psItem = IMG_CONTAINER_OF(psNode,
struct DIIB_WORK_ITEM,
sQueueElement);
dllist_remove_node(psNode);
_ContextUnrefAndMaybeDestroy(psItem->psContext);
OSFreeMem(psItem);
}
OSLockRelease(_g_psImpl->psWriterLock);
eError = OSEventObjectClose(hEvent);
PVR_LOG_IF_ERROR(eError, "OSEventObjectClose");
OSAtomicWrite(&_g_psImpl->eThreadState, THREAD_STATE_TERMINATED);
}
/* ----- DI internal API ---------------------------------------------------- */
DIIB_ENTRY *DIImplBrgFind(const IMG_CHAR *pszPath)
{
DIIB_ENTRY *psEntry;
OSWRLockAcquireRead(_g_psImpl->psEntriesLock);
psEntry = (void *) HASH_Retrieve_Extended(_g_psImpl->psEntriesTable,
(IMG_CHAR *) pszPath);
OSWRLockReleaseRead(_g_psImpl->psEntriesLock);
return psEntry;
}
/* ----- DI bridge interface ------------------------------------------------ */
static PVRSRV_ERROR _CreateStream(IMG_CHAR *pszStreamName, IMG_HANDLE *phStream)
{
IMG_UINT32 iRet;
IMG_HANDLE hStream;
PVRSRV_ERROR eError;
/* for now only one stream can be created. Should we be able to create
* per context stream? */
iRet = OSSNPrintf(pszStreamName, PVRSRVTL_MAX_STREAM_NAME_SIZE,
"di_stream_%x", OSGetCurrentClientProcessIDKM());
if (iRet >= PVRSRVTL_MAX_STREAM_NAME_SIZE)
{
/* this check is superfluous because it can never happen but in case
* someone changes the definition of PVRSRVTL_MAX_STREAM_NAME_SIZE
* handle this case */
pszStreamName[0] = '\0';
return PVRSRV_ERROR_INTERNAL_ERROR;
}
eError = TLStreamCreate(&hStream, pszStreamName, STREAM_BUFFER_SIZE,
TL_OPMODE_DROP_NEWER, NULL, NULL, NULL, NULL,
NULL, NULL);
PVR_RETURN_IF_ERROR(eError);
*phStream = hStream;
return PVRSRV_OK;
}
PVRSRV_ERROR DICreateContextKM(IMG_CHAR *pszStreamName, DI_CONTEXT **ppsContext)
{
PVRSRV_ERROR eError;
DI_CONTEXT *psContext;
IMG_HANDLE hStream = NULL;
THREAD_STATE eTState;
PVR_LOG_RETURN_IF_INVALID_PARAM(ppsContext != NULL, "ppsContext");
PVR_LOG_RETURN_IF_INVALID_PARAM(pszStreamName != NULL, "pszStreamName");
psContext = OSAllocMem(sizeof(*psContext));
PVR_LOG_GOTO_IF_NOMEM(psContext, eError, return_);
eError = _CreateStream(pszStreamName, &hStream);
PVR_LOG_GOTO_IF_ERROR(eError, "_CreateStream", free_desc_);
psContext->hStream = hStream;
/* indicated to the write thread if the client is still connected and
* waiting for the data */
psContext->bClientConnected = IMG_TRUE;
OSAtomicWrite(&psContext->iRefCnt, 1);
eTState = OSAtomicCompareExchange(&_g_psImpl->eThreadState,
THREAD_STATE_NULL,
THREAD_STATE_ALIVE);
/* if the thread has not been started yet do it */
if (eTState == THREAD_STATE_NULL)
{
PVR_ASSERT(_g_psImpl->hWriterThread == NULL);
eError = OSThreadCreate(&_g_psImpl->hWriterThread, "di_writer",
_WriterThread, NULL, IMG_FALSE, NULL);
PVR_LOG_GOTO_IF_ERROR(eError, "OSThreadCreate", free_close_stream_);
}
*ppsContext = psContext;
return PVRSRV_OK;
free_close_stream_:
TLStreamClose(psContext->hStream);
OSAtomicWrite(&_g_psImpl->eThreadState, THREAD_STATE_TERMINATED);
free_desc_:
OSFreeMem(psContext);
return_:
return eError;
}
PVRSRV_ERROR DIDestroyContextKM(DI_CONTEXT *psContext)
{
PVR_LOG_RETURN_IF_INVALID_PARAM(psContext != NULL, "psContext");
/* pass the information to the write thread that the client has
* disconnected */
psContext->bClientConnected = IMG_FALSE;
return _ContextUnrefAndMaybeDestroy(psContext);
}
PVRSRV_ERROR DIReadEntryKM(DI_CONTEXT *psContext, const IMG_CHAR *pszEntryPath,
IMG_UINT64 ui64Offset, IMG_UINT64 ui64Size)
{
PVRSRV_ERROR eError;
struct DIIB_WORK_ITEM *psItem;
PVR_LOG_RETURN_IF_INVALID_PARAM(psContext != NULL, "psContext");
PVR_LOG_RETURN_IF_INVALID_PARAM(pszEntryPath != NULL, "pszEntryPath");
/* 'no stats' to avoid acquiring the process stats locks */
psItem = OSAllocMemNoStats(sizeof(*psItem));
PVR_LOG_GOTO_IF_NOMEM(psItem, eError, return_);
psItem->psContext = psContext;
psItem->psEntry = DIImplBrgFind(pszEntryPath);
PVR_LOG_GOTO_IF_FALSE_VA(psItem->psEntry != NULL, free_item_,
"entry %s does not exist", pszEntryPath);
psItem->ui64Size = ui64Size;
psItem->ui64Offset = ui64Offset;
/* increment ref count on the context so that it doesn't get freed
* before it gets processed by the writer thread. */
if (OSAtomicAddUnless(&psContext->iRefCnt, 1, IMG_INT32_MAX) == IMG_INT32_MAX)
{
/* Job is not scheduled to the writer queue; there are too many waiting. */
PVR_LOG_GOTO_WITH_ERROR("OSAtomicAddUnless", eError, PVRSRV_ERROR_REFCOUNT_OVERFLOW, overflow_);
}
OSLockAcquire(_g_psImpl->psWriterLock);
dllist_add_to_head(&_g_psImpl->sWriterQueue, &psItem->sQueueElement);
OSLockRelease(_g_psImpl->psWriterLock);
eError = OSEventObjectSignal(_g_psImpl->hWriterEventObject);
PVR_LOG_IF_ERROR(eError, "OSEventObjectSignal");
return PVRSRV_OK;
free_item_:
eError = PVRSRV_ERROR_NOT_FOUND;
overflow_:
OSFreeMemNoStats(psItem);
return_:
return eError;
}
PVRSRV_ERROR DIWriteEntryKM(DI_CONTEXT *psContext, const IMG_CHAR *pszEntryPath,
IMG_UINT32 ui32ValueSize, const IMG_CHAR *pszValue)
{
DIIB_ENTRY *psEntry;
DI_PFN_WRITE pfnEntryPuts;
IMG_INT64 i64Length = 0;
PVR_LOG_RETURN_IF_INVALID_PARAM(psContext != NULL, "psContext");
PVR_LOG_RETURN_IF_INVALID_PARAM(pszEntryPath != NULL, "pszEntryPath");
PVR_LOG_RETURN_IF_INVALID_PARAM(pszValue != NULL, "pszValue");
psEntry = DIImplBrgFind(pszEntryPath);
PVR_LOG_RETURN_IF_FALSE_VA(psEntry != NULL, PVRSRV_ERROR_NOT_FOUND,
"entry %s does not exist", pszEntryPath);
pfnEntryPuts = psEntry->sIterCb.pfnWrite;
if (pfnEntryPuts != NULL)
{
i64Length = pfnEntryPuts(pszValue, ui32ValueSize, (IMG_UINT64*)&i64Length, psEntry->pvPrivData);
/* To deal with -EINVAL being returned */
PVR_LOG_RETURN_IF_INVALID_PARAM(i64Length >= 0, pszValue);
}
else
{
PVR_LOG_MSG(PVR_DBG_ERROR, "Unable to write to DI file, writing is not supported for this file.");
return PVRSRV_ERROR_INVALID_REQUEST;
}
return PVRSRV_OK;
}
static PVRSRV_ERROR _listName(uintptr_t k,
uintptr_t v,
void* hStream)
{
PVRSRV_ERROR eError;
DIIB_ENTRY *psEntry;
IMG_UINT32 ui32Size;
IMG_CHAR aszName[DI_IMPL_BRG_PATH_LEN];
psEntry = (DIIB_ENTRY*) v;
PVR_ASSERT(psEntry != NULL);
PVR_UNREFERENCED_PARAMETER(k);
ui32Size = OSSNPrintf(aszName, DI_IMPL_BRG_PATH_LEN, "%s\n", psEntry->pszFullPath);
PVR_LOG_IF_FALSE(ui32Size > 5, "ui32Size too small, Error suspected!");
eError = TLStreamWrite(hStream, (IMG_UINT8 *)aszName, ui32Size+1);
return eError;
}
PVRSRV_ERROR DIListAllEntriesKM(DI_CONTEXT *psContext)
{
PVRSRV_ERROR eError;
PVR_LOG_RETURN_IF_INVALID_PARAM(psContext != NULL, "psContext");
OSWRLockAcquireRead(_g_psImpl->psEntriesLock);
eError = HASH_Iterate(_g_psImpl->psEntriesTable, _listName, psContext->hStream);
OSWRLockReleaseRead(_g_psImpl->psEntriesLock);
PVR_LOG_IF_ERROR(eError, "HASH_Iterate_Extended");
eError = TLStreamMarkEOS(psContext->hStream, IMG_FALSE);
return eError;
}
/* ----- DI implementation interface ---------------------------------------- */
static PVRSRV_ERROR _Init(void)
{
PVRSRV_ERROR eError;
_g_psImpl = OSAllocMem(sizeof(*_g_psImpl));
PVR_LOG_GOTO_IF_NOMEM(_g_psImpl, eError, return_);
_g_psImpl->psEntriesTable = HASH_Create_Extended(ENTRIES_TABLE_INIT_SIZE,
DI_IMPL_BRG_PATH_LEN,
HASH_Djb2_Hash,
HASH_Djb2_Compare);
PVR_LOG_GOTO_IF_NOMEM(_g_psImpl->psEntriesTable, eError, free_impl_);
eError = OSWRLockCreate(&_g_psImpl->psEntriesLock);
PVR_LOG_GOTO_IF_ERROR(eError, "OSCreateLock", free_table_);
eError = OSLockCreate(&_g_psImpl->psWriterLock);
PVR_LOG_GOTO_IF_ERROR(eError, "OSCreateLock", free_entries_lock_);
eError = OSEventObjectCreate("DI_WRITER_EO",
&_g_psImpl->hWriterEventObject);
PVR_LOG_GOTO_IF_ERROR(eError, "OSEventObjectCreate", free_writer_lock_);
_g_psImpl->hWriterThread = NULL;
OSAtomicWrite(&_g_psImpl->eThreadState, THREAD_STATE_NULL);
dllist_init(&_g_psImpl->sWriterQueue);
return PVRSRV_OK;
free_writer_lock_:
OSLockDestroy(_g_psImpl->psWriterLock);
free_entries_lock_:
OSWRLockDestroy(_g_psImpl->psEntriesLock);
free_table_:
HASH_Delete_Extended(_g_psImpl->psEntriesTable, IMG_FALSE);
free_impl_:
OSFreeMem(_g_psImpl);
_g_psImpl = NULL;
return_:
return eError;
}
static void _DeInit(void)
{
PVRSRV_ERROR eError = PVRSRV_OK;
THREAD_STATE eTState;
eTState = OSAtomicCompareExchange(&_g_psImpl->eThreadState,
THREAD_STATE_ALIVE,
THREAD_STATE_TERMINATED);
if (eTState == THREAD_STATE_ALIVE)
{
if (_g_psImpl->hWriterEventObject != NULL)
{
eError = OSEventObjectSignal(_g_psImpl->hWriterEventObject);
PVR_LOG_IF_ERROR(eError, "OSEventObjectSignal");
}
LOOP_UNTIL_TIMEOUT_US(WRITER_THREAD_DESTROY_TIMEOUT)
{
eError = OSThreadDestroy(_g_psImpl->hWriterThread);
if (eError == PVRSRV_OK)
{
break;
}
OSWaitus(WRITER_THREAD_DESTROY_TIMEOUT/WRITER_THREAD_DESTROY_RETRIES);
} END_LOOP_UNTIL_TIMEOUT_US();
PVR_LOG_IF_ERROR(eError, "OSThreadDestroy");
}
if (_g_psImpl->hWriterEventObject != NULL)
{
eError = OSEventObjectDestroy(_g_psImpl->hWriterEventObject);
PVR_LOG_IF_ERROR(eError, "OSEventObjectDestroy");
}
HASH_Delete_Extended(_g_psImpl->psEntriesTable, IMG_FALSE);
OSLockDestroy(_g_psImpl->psWriterLock);
OSWRLockDestroy(_g_psImpl->psEntriesLock);
OSFreeMem(_g_psImpl);
_g_psImpl = NULL;
}
/* Recursively traverses the ancestors list up to the root group and
* appends their names preceded by "/" to the path in reverse order
* (root group's name first and psGroup group's name last).
* Returns current offset in the path (the current path length without the
* NUL character). If there is no more space in the path returns -1
* to indicate an error (the path is too long to fit into the buffer). */
static ssize_t _BuildGroupPath(IMG_CHAR *pszPath, const DIIB_GROUP *psGroup)
{
ssize_t iOff;
ssize_t iCopiedCnt;
size_t uFreeCnt;
PVR_RETURN_IF_FALSE(psGroup != NULL, 0);
PVR_ASSERT(pszPath != NULL);
iOff = _BuildGroupPath(pszPath, psGroup->psParentGroup);
PVR_RETURN_IF_FALSE(iOff != -1, -1);
uFreeCnt = DI_IMPL_BRG_PATH_LEN - iOff;
PVR_RETURN_IF_FALSE(uFreeCnt > 1, -1);
pszPath[iOff++] = '/';
--uFreeCnt;
iCopiedCnt = OSStringSafeCopy(&pszPath[iOff], psGroup->pszName, uFreeCnt);
PVR_RETURN_IF_FALSE(iCopiedCnt >= 0, -1);
iOff += iCopiedCnt;
return iOff;
}
static PVRSRV_ERROR _BuildEntryPath(IMG_CHAR *pszPath, const IMG_CHAR *pszName,
const DIIB_GROUP *psGroup)
{
ssize_t iOff = _BuildGroupPath(pszPath, psGroup);
ssize_t iCopiedCnt;
size_t uFreeCnt;
PVR_RETURN_IF_FALSE(iOff != -1, PVRSRV_ERROR_INVALID_OFFSET);
uFreeCnt = DI_IMPL_BRG_PATH_LEN - iOff;
PVR_RETURN_IF_FALSE(uFreeCnt > 1, PVRSRV_ERROR_OUT_OF_MEMORY);
pszPath[iOff++] = '/';
--uFreeCnt;
iCopiedCnt = OSStringSafeCopy(&pszPath[iOff], pszName, uFreeCnt);
PVR_RETURN_IF_FALSE(iCopiedCnt >= 0, PVRSRV_ERROR_OUT_OF_MEMORY);
return PVRSRV_OK;
}
static PVRSRV_ERROR _CreateEntry(const IMG_CHAR *pszName,
DI_ENTRY_TYPE eType,
const DI_ITERATOR_CB *psIterCb,
void *pvPrivData,
void *pvParentGroup,
void **pvEntry)
{
DIIB_GROUP *psParentGroup = pvParentGroup;
DIIB_ENTRY *psEntry;
PVRSRV_ERROR eError;
PVR_LOG_RETURN_IF_INVALID_PARAM(pvEntry != NULL, "pvEntry");
PVR_LOG_RETURN_IF_INVALID_PARAM(pvParentGroup != NULL, "pvParentGroup");
switch (eType)
{
case DI_ENTRY_TYPE_GENERIC:
break;
case DI_ENTRY_TYPE_RANDOM_ACCESS:
break;
default:
PVR_DPF((PVR_DBG_ERROR, "eType invalid in %s()", __func__));
PVR_GOTO_WITH_ERROR(eError, PVRSRV_ERROR_INVALID_PARAMS, return_);
}
psEntry = OSAllocMem(sizeof(*psEntry));
PVR_LOG_GOTO_IF_NOMEM(psEntry, eError, return_);
eError = OSLockCreate(&psEntry->hLock);
PVR_LOG_GOTO_IF_ERROR(eError, "OSLockCreate", free_entry_);
psEntry->eType = eType;
psEntry->sIterCb = *psIterCb;
psEntry->pvPrivData = pvPrivData;
psEntry->psParentGroup = psParentGroup;
psEntry->pszFullPath[0] = '\0';
psEntry->sImplEntry.pvPrivData = pvPrivData;
psEntry->sImplEntry.pvNative = NULL;
psEntry->sImplEntry.psCb = &_g_sEntryCallbacks;
eError = _BuildEntryPath(psEntry->pszFullPath, pszName,
psEntry->psParentGroup);
if (eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR, "%s() failed in _BuildEntryPath() for \"%s\" "
"entry", __func__, pszName));
goto destroy_lock_;
}
OSWRLockAcquireWrite(_g_psImpl->psEntriesLock);
eError = HASH_Insert_Extended(_g_psImpl->psEntriesTable,
psEntry->pszFullPath,
(uintptr_t) psEntry) ?
PVRSRV_OK : PVRSRV_ERROR_UNABLE_TO_ADD_HANDLE;
OSWRLockReleaseWrite(_g_psImpl->psEntriesLock);
PVR_LOG_GOTO_IF_ERROR(eError, "HASH_Insert_Extended failed", destroy_lock_);
*pvEntry = psEntry;
return PVRSRV_OK;
destroy_lock_:
OSLockDestroy(psEntry->hLock);
free_entry_:
OSFreeMem(psEntry);
return_:
return eError;
}
static void _DestroyEntry(void *pvEntry)
{
DIIB_ENTRY *psEntry = pvEntry;
PVR_ASSERT(psEntry != NULL);
OSWRLockAcquireWrite(_g_psImpl->psEntriesLock);
HASH_Remove_Extended(_g_psImpl->psEntriesTable, psEntry->pszFullPath);
OSWRLockReleaseWrite(_g_psImpl->psEntriesLock);
OSLockDestroy(psEntry->hLock);
OSFreeMem(psEntry);
}
static PVRSRV_ERROR _CreateGroup(const IMG_CHAR *pszName,
void *pvParentGroup,
void **ppvGroup)
{
DIIB_GROUP *psNewGroup;
PVR_LOG_RETURN_IF_INVALID_PARAM(pszName != NULL, "pszName");
PVR_LOG_RETURN_IF_INVALID_PARAM(ppvGroup != NULL, "ppvGroup");
psNewGroup = OSAllocMem(sizeof(*psNewGroup));
PVR_LOG_RETURN_IF_NOMEM(psNewGroup, "OSAllocMem");
psNewGroup->pszName = pszName;
psNewGroup->psParentGroup = pvParentGroup;
*ppvGroup = psNewGroup;
return PVRSRV_OK;
}
static void _DestroyGroup(void *pvGroup)
{
DIIB_GROUP *psGroup = pvGroup;
PVR_ASSERT(psGroup != NULL);
OSFreeMem(psGroup);
}
PVRSRV_ERROR PVRDIImplBrgRegister(void)
{
OSDI_IMPL_CB sImplCb = {
.pfnInit = _Init,
.pfnDeInit = _DeInit,
.pfnCreateEntry = _CreateEntry,
.pfnDestroyEntry = _DestroyEntry,
.pfnCreateGroup = _CreateGroup,
.pfnDestroyGroup = _DestroyGroup
};
return DIRegisterImplementation("impl_brg", &sImplCb);
}
/******************************************************************************
End of file (di_impl_brg.c)
******************************************************************************/

View File

@@ -0,0 +1,94 @@
/*************************************************************************/ /*!
@File
@Title OS agnostic implementation of Debug Info interface.
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef PVR_IMPL_BRG_H
#define PVR_IMPL_BRG_H
#include "pvrsrv_error.h"
#include "lock_types.h"
typedef struct DI_CONTEXT_TAG DI_CONTEXT;
typedef struct DI_ENTRY_DESC DI_ENTRY_DESC;
PVRSRV_ERROR PVRDIImplBrgRegister(void);
/*! @Function DICreateContextKM
*
* @Description
* Creates DI context which among others also creates a TL stream for reading
* entries.
*
* @Output pszStreamName: name of the TL stream created in this context
* @Output ppsContext: pointer to the new context
*
* @Return PVRSRV_ERROR error code
* PVRSRV_OK in case of a success
* PVRSRV_ERROR_INVALID_PARAMS if any of the parameters is invalid
* PVRSRV_ERROR_OUT_OF_MEMORY if any of the memory allocations failed
* error codes returned by TLStreamCreate()
*/
PVRSRV_ERROR DICreateContextKM(IMG_CHAR *pszStreamName,
DI_CONTEXT **ppsContext);
/*! @Function DIDestroyContextKM
*
* @Description
* Destroy the DI context and all underlying dependencies.
*
* @Input psContext: pointer to the context
*
* @Return PVRSRV_ERROR error code
* PVRSRV_OK in case of a success
* PVRSRV_ERROR_INVALID_PARAMS if invalid context pointer given
*/
PVRSRV_ERROR DIDestroyContextKM(DI_CONTEXT *psContext);
PVRSRV_ERROR DIReadEntryKM(DI_CONTEXT *psContext, const IMG_CHAR *pszEntryPath,
IMG_UINT64 ui64Offset, IMG_UINT64 ui64Size);
PVRSRV_ERROR DIWriteEntryKM(DI_CONTEXT *psContext, const IMG_CHAR *pszEntryPath,
IMG_UINT32 ui32ValueSize, const IMG_CHAR *pszValue);
PVRSRV_ERROR DIListAllEntriesKM(DI_CONTEXT *psContext);
#endif /* PVR_IMPL_BRG_H */

View File

@@ -0,0 +1,61 @@
/*************************************************************************/ /*!
@File
@Title OS agnostic implementation of Debug Info internal interface.
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef PVR_IMPL_BRG_INTERN_H
#define PVR_IMPL_BRG_INTERN_H
typedef struct DIIB_GROUP DIIB_GROUP;
typedef struct DIIB_ENTRY DIIB_ENTRY;
/*! @Function DIImplBrgFind
*
* @Description
* Retrieves an entry based on a given path.
*
* @Input pszPath: Full entry path in form of
* /rootGroup/.../parentGroup/entryName.
*
* @Return Returns entry object if exists or NULL otherwise.
*/
DIIB_ENTRY *DIImplBrgFind(const IMG_CHAR *pszPath);
#endif /* PVR_IMPL_BRG_INTERN_H */

View File

@@ -0,0 +1,800 @@
/*************************************************************************/ /*!
@File
@Title Debug Info framework functions and types.
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#include "di_server.h"
#include "osdi_impl.h"
#include "pvrsrv_error.h"
#include "dllist.h"
#include "lock.h"
#include "allocmem.h"
#include "osfunc.h"
#define ROOT_GROUP_NAME PVR_DRM_NAME
/*! Implementation object. */
typedef struct DI_IMPL
{
const IMG_CHAR *pszName; /*<! name of the implementation */
OSDI_IMPL_CB sCb; /*<! implementation callbacks */
IMG_BOOL bInitialised; /*<! set to IMG_TRUE after implementation
is initialised */
DLLIST_NODE sListNode; /*<! node element of the global list of all
implementations */
} DI_IMPL;
/*! Wrapper object for objects originating from derivative implementations.
* This wraps both entries and groups native implementation objects. */
typedef struct DI_NATIVE_HANDLE
{
void *pvHandle; /*!< opaque handle to the native object */
DI_IMPL *psDiImpl; /*!< implementation pvHandle is associated
with */
DLLIST_NODE sListNode; /*!< node element of native handles list */
} DI_NATIVE_HANDLE;
/*! Debug Info entry object.
*
* Depending on the implementation this can be represented differently. For
* example for the DebugFS this translates to a file.
*/
struct DI_ENTRY
{
const IMG_CHAR *pszName; /*!< name of the entry */
void *pvPrivData; /*! handle to entry's private data */
DI_ENTRY_TYPE eType; /*! entry type */
DI_ITERATOR_CB sIterCb; /*!< iterator interface for the entry */
DLLIST_NODE sListNode; /*!< node element of group's entry list */
DLLIST_NODE sNativeHandleList; /*!< list of native handles belonging to this
entry */
};
/*! Debug Info group object.
*
* Depending on the implementation this can be represented differently. For
* example for the DebugFS this translates to a directory.
*/
struct DI_GROUP
{
IMG_CHAR *pszName; /*!< name of the group */
const struct DI_GROUP *psParent; /*!< parent groups */
DLLIST_NODE sListNode; /*!< node element of group's group list */
DLLIST_NODE sGroupList; /*!< list of groups (children) that belong
to this group */
DLLIST_NODE sEntryList; /*!< list of entries (children) that belong
to this group */
DLLIST_NODE sNativeHandleList; /*!< list of native handles belonging to
this group */
};
/* List of all registered implementations. */
static DECLARE_DLLIST(_g_sImpls);
/* Root group for the DI entries and groups. This group is used as a root
* group for all other groups and entries if during creation a parent groups
* is not given. */
static DI_GROUP *_g_psRootGroup;
/* Protects access to _g_sImpls and _g_psRootGroup */
static POS_LOCK _g_hLock;
PVRSRV_ERROR DIInit(void)
{
PVRSRV_ERROR eError;
#if defined(__linux__) && defined(__KERNEL__)
eError = OSLockCreateNoStats(&_g_hLock);
#else
eError = OSLockCreate(&_g_hLock);
#endif
PVR_LOG_GOTO_IF_ERROR(eError, "OSLockCreate", return_);
_g_psRootGroup = OSAllocMemNoStats(sizeof(*_g_psRootGroup));
PVR_LOG_GOTO_IF_NOMEM(_g_psRootGroup, eError, destroy_lock_);
_g_psRootGroup->pszName = OSAllocMemNoStats(sizeof(ROOT_GROUP_NAME));
PVR_LOG_GOTO_IF_NOMEM(_g_psRootGroup->pszName, eError, cleanup_name_);
OSStringSafeCopy(_g_psRootGroup->pszName, ROOT_GROUP_NAME,
sizeof(ROOT_GROUP_NAME));
dllist_init(&_g_psRootGroup->sListNode);
dllist_init(&_g_psRootGroup->sGroupList);
dllist_init(&_g_psRootGroup->sEntryList);
dllist_init(&_g_psRootGroup->sNativeHandleList);
return PVRSRV_OK;
cleanup_name_:
OSFreeMemNoStats(_g_psRootGroup);
destroy_lock_:
#if defined(__linux__) && defined(__KERNEL__)
OSLockDestroyNoStats(_g_hLock);
#else
OSLockDestroy(_g_hLock);
#endif
return_:
return eError;
}
/* Destroys the whole tree of group and entries for a given group as a root. */
static void _DeInitGroupRecursively(DI_GROUP *psGroup)
{
DLLIST_NODE *psThis, *psNext;
dllist_foreach_node(&psGroup->sEntryList, psThis, psNext)
{
DI_ENTRY *psThisEntry = IMG_CONTAINER_OF(psThis, DI_ENTRY, sListNode);
DIDestroyEntry(psThisEntry);
}
dllist_foreach_node(&psGroup->sGroupList, psThis, psNext)
{
DI_GROUP *psThisGroup = IMG_CONTAINER_OF(psThis, DI_GROUP, sListNode);
_DeInitGroupRecursively(psThisGroup);
}
DIDestroyGroup(psGroup);
}
void DIDeInit(void)
{
DLLIST_NODE *psThis, *psNext;
OSLockAcquire(_g_hLock);
if (!dllist_is_empty(&_g_psRootGroup->sGroupList) ||
!dllist_is_empty(&_g_psRootGroup->sEntryList))
{
PVR_DPF((PVR_DBG_WARNING, "%s: entries or groups still exist during "
"de-initialisation process, destroying all", __func__));
}
_DeInitGroupRecursively(_g_psRootGroup);
_g_psRootGroup = NULL;
/* Remove all of the implementations. */
dllist_foreach_node(&_g_sImpls, psThis, psNext)
{
DI_IMPL *psDiImpl = IMG_CONTAINER_OF(psThis, DI_IMPL, sListNode);
if (psDiImpl->bInitialised)
{
psDiImpl->sCb.pfnDeInit();
psDiImpl->bInitialised = IMG_FALSE;
}
dllist_remove_node(&psDiImpl->sListNode);
OSFreeMem(psDiImpl);
}
OSLockRelease(_g_hLock);
/* all resources freed so free the lock itself too */
#if defined(__linux__) && defined(__KERNEL__)
OSLockDestroyNoStats(_g_hLock);
#else
OSLockDestroy(_g_hLock);
#endif
}
static IMG_BOOL _ValidateIteratorCb(const DI_ITERATOR_CB *psIterCb,
DI_ENTRY_TYPE eType)
{
IMG_UINT32 uiFlags = 0;
if (psIterCb == NULL)
{
return IMG_FALSE;
}
if (eType == DI_ENTRY_TYPE_GENERIC)
{
uiFlags |= psIterCb->pfnShow != NULL ? BIT(0) : 0;
uiFlags |= psIterCb->pfnStart != NULL ? BIT(1) : 0;
uiFlags |= psIterCb->pfnStop != NULL ? BIT(2) : 0;
uiFlags |= psIterCb->pfnNext != NULL ? BIT(3) : 0;
/* either only pfnShow or all callbacks need to be set */
if (uiFlags != BIT(0) && !BITMASK_HAS(uiFlags, 0x0f))
{
return IMG_FALSE;
}
}
else if (eType == DI_ENTRY_TYPE_RANDOM_ACCESS)
{
uiFlags |= psIterCb->pfnRead != NULL ? BIT(0) : 0;
uiFlags |= psIterCb->pfnSeek != NULL ? BIT(1) : 0;
/* either only pfnRead or all callbacks need to be set */
if (uiFlags != BIT(0) && !BITMASK_HAS(uiFlags, 0x03))
{
return IMG_FALSE;
}
}
else
{
return IMG_FALSE;
}
return IMG_TRUE;
}
static PVRSRV_ERROR _CreateNativeEntry(DI_ENTRY *psEntry,
const DI_NATIVE_HANDLE *psNativeParent)
{
PVRSRV_ERROR eError;
DI_IMPL *psImpl = psNativeParent->psDiImpl;
DI_NATIVE_HANDLE *psNativeEntry = OSAllocMem(sizeof(*psNativeEntry));
PVR_LOG_GOTO_IF_NOMEM(psNativeEntry, eError, return_);
eError = psImpl->sCb.pfnCreateEntry(psEntry->pszName,
psEntry->eType,
&psEntry->sIterCb,
psEntry->pvPrivData,
psNativeParent->pvHandle,
&psNativeEntry->pvHandle);
PVR_LOG_GOTO_IF_ERROR(eError, "psImpl->sCb.pfnCreateEntry", free_memory_);
psNativeEntry->psDiImpl = psImpl;
dllist_add_to_head(&psEntry->sNativeHandleList, &psNativeEntry->sListNode);
return PVRSRV_OK;
free_memory_:
OSFreeMem(psNativeEntry);
return_:
return eError;
}
static void _DestroyNativeEntry(DI_NATIVE_HANDLE *psNativeEntry)
{
psNativeEntry->psDiImpl->sCb.pfnDestroyEntry(psNativeEntry->pvHandle);
dllist_remove_node(&psNativeEntry->sListNode);
OSFreeMem(psNativeEntry);
}
PVRSRV_ERROR DICreateEntry(const IMG_CHAR *pszName,
DI_GROUP *psGroup,
const DI_ITERATOR_CB *psIterCb,
void *pvPriv,
DI_ENTRY_TYPE eType,
DI_ENTRY **ppsEntry)
{
PVRSRV_ERROR eError;
DLLIST_NODE *psThis, *psNext;
DI_ENTRY *psEntry;
PVR_LOG_RETURN_IF_INVALID_PARAM(pszName != NULL, "pszName");
PVR_LOG_RETURN_IF_INVALID_PARAM(_ValidateIteratorCb(psIterCb, eType),
"psIterCb");
PVR_LOG_RETURN_IF_INVALID_PARAM(ppsEntry != NULL, "psEntry");
psEntry = OSAllocMem(sizeof(*psEntry));
PVR_LOG_RETURN_IF_NOMEM(psEntry, "OSAllocMem");
if (psGroup == NULL)
{
psGroup = _g_psRootGroup;
}
psEntry->pszName = pszName;
psEntry->pvPrivData = pvPriv;
psEntry->eType = eType;
psEntry->sIterCb = *psIterCb;
dllist_init(&psEntry->sNativeHandleList);
OSLockAcquire(_g_hLock);
/* Iterate over all of the native handles of parent group to create
* the entry for every registered implementation. */
dllist_foreach_node(&psGroup->sNativeHandleList, psThis, psNext)
{
DI_NATIVE_HANDLE *psNativeGroup =
IMG_CONTAINER_OF(psThis, DI_NATIVE_HANDLE, sListNode);
eError = _CreateNativeEntry(psEntry, psNativeGroup);
PVR_GOTO_IF_ERROR(eError, cleanup_);
}
dllist_add_to_tail(&psGroup->sEntryList, &psEntry->sListNode);
OSLockRelease(_g_hLock);
*ppsEntry = psEntry;
return PVRSRV_OK;
cleanup_:
OSLockRelease(_g_hLock);
/* Something went wrong so if there were any native entries created remove
* them from the list, free them and free the DI entry itself. */
dllist_foreach_node(&psEntry->sNativeHandleList, psThis, psNext)
{
DI_NATIVE_HANDLE *psNativeEntry =
IMG_CONTAINER_OF(psThis, DI_NATIVE_HANDLE, sListNode);
_DestroyNativeEntry(psNativeEntry);
}
OSFreeMem(psEntry);
return eError;
}
void DIDestroyEntry(DI_ENTRY *psEntry)
{
DLLIST_NODE *psThis, *psNext;
PVR_LOG_RETURN_VOID_IF_FALSE(psEntry != NULL,
"psEntry invalid in DIDestroyEntry()");
/* Iterate through all of the native entries of the DI entry, remove
* them from the list and then destroy them. After that, destroy the
* DI entry itself. */
dllist_foreach_node(&psEntry->sNativeHandleList, psThis, psNext)
{
DI_NATIVE_HANDLE *psNative = IMG_CONTAINER_OF(psThis, DI_NATIVE_HANDLE,
sListNode);
/* The implementation must ensure that entry is not removed if any
* operations are being executed on the entry. If this is the case
* the implementation should block until all of them are finished
* and prevent any further operations.
* This will guarantee proper synchronisation between the DI framework
* and underlying implementations and prevent destruction/access
* races. */
_DestroyNativeEntry(psNative);
}
dllist_remove_node(&psEntry->sListNode);
OSFreeMem(psEntry);
}
static PVRSRV_ERROR _CreateNativeGroup(DI_GROUP *psGroup,
const DI_NATIVE_HANDLE *psNativeParent,
DI_NATIVE_HANDLE **ppsNativeGroup)
{
PVRSRV_ERROR eError;
DI_IMPL *psImpl = psNativeParent->psDiImpl;
DI_NATIVE_HANDLE *psNativeGroup = OSAllocMem(sizeof(*psNativeGroup));
PVR_LOG_GOTO_IF_NOMEM(psNativeGroup, eError, return_);
eError = psImpl->sCb.pfnCreateGroup(psGroup->pszName,
psNativeParent->pvHandle,
&psNativeGroup->pvHandle);
PVR_LOG_GOTO_IF_ERROR(eError, "psImpl->sCb.pfnCreateGroup", free_memory_);
psNativeGroup->psDiImpl = psImpl;
dllist_add_to_head(&psGroup->sNativeHandleList, &psNativeGroup->sListNode);
*ppsNativeGroup = psNativeGroup;
return PVRSRV_OK;
free_memory_:
OSFreeMem(psNativeGroup);
return_:
return eError;
}
static void _DestroyNativeGroup(DI_NATIVE_HANDLE *psNativeGroup)
{
psNativeGroup->psDiImpl->sCb.pfnDestroyGroup(psNativeGroup->pvHandle);
dllist_remove_node(&psNativeGroup->sListNode);
OSFreeMem(psNativeGroup);
}
PVRSRV_ERROR DICreateGroup(const IMG_CHAR *pszName,
DI_GROUP *psParent,
DI_GROUP **ppsGroup)
{
PVRSRV_ERROR eError;
DLLIST_NODE *psThis, *psNext;
DI_GROUP *psGroup;
size_t uSize;
PVR_LOG_RETURN_IF_INVALID_PARAM(pszName != NULL, "pszName");
PVR_LOG_RETURN_IF_INVALID_PARAM(ppsGroup != NULL, "ppsDiGroup");
psGroup = OSAllocMem(sizeof(*psGroup));
PVR_LOG_RETURN_IF_NOMEM(psGroup, "OSAllocMem");
if (psParent == NULL)
{
psParent = _g_psRootGroup;
}
uSize = OSStringLength(pszName) + 1;
psGroup->pszName = OSAllocMem(uSize * sizeof(*psGroup->pszName));
PVR_LOG_GOTO_IF_NOMEM(psGroup->pszName, eError, cleanup_name_);
OSStringSafeCopy(psGroup->pszName, pszName, uSize);
psGroup->psParent = psParent;
dllist_init(&psGroup->sGroupList);
dllist_init(&psGroup->sEntryList);
dllist_init(&psGroup->sNativeHandleList);
OSLockAcquire(_g_hLock);
/* Iterate over all of the native handles of parent group to create
* the group for every registered implementation. */
dllist_foreach_node(&psParent->sNativeHandleList, psThis, psNext)
{
DI_NATIVE_HANDLE *psNativeGroup = NULL, *psNativeParent =
IMG_CONTAINER_OF(psThis, DI_NATIVE_HANDLE, sListNode);
eError = _CreateNativeGroup(psGroup, psNativeParent, &psNativeGroup);
PVR_GOTO_IF_ERROR(eError, cleanup_);
}
dllist_add_to_tail(&psParent->sGroupList, &psGroup->sListNode);
OSLockRelease(_g_hLock);
*ppsGroup = psGroup;
return PVRSRV_OK;
cleanup_:
OSLockRelease(_g_hLock);
/* Something went wrong so if there were any native groups created remove
* them from the list, free them and free the DI group itself. */
dllist_foreach_node(&psGroup->sNativeHandleList, psThis, psNext)
{
DI_NATIVE_HANDLE *psNativeGroup =
IMG_CONTAINER_OF(psThis, DI_NATIVE_HANDLE, sListNode);
_DestroyNativeGroup(psNativeGroup);
}
OSFreeMem(psGroup->pszName);
cleanup_name_:
OSFreeMem(psGroup);
return eError;
}
void DIDestroyGroup(DI_GROUP *psGroup)
{
DLLIST_NODE *psThis, *psNext;
PVR_LOG_RETURN_VOID_IF_FALSE(psGroup != NULL,
"psGroup invalid in DIDestroyGroup()");
/* Iterate through all of the native groups of the DI group, remove
* them from the list and then destroy them. After that destroy the
* DI group itself. */
dllist_foreach_node(&psGroup->sNativeHandleList, psThis, psNext)
{
DI_NATIVE_HANDLE *psNative = IMG_CONTAINER_OF(psThis, DI_NATIVE_HANDLE,
sListNode);
psNative->psDiImpl->sCb.pfnDestroyGroup(psNative->pvHandle);
dllist_remove_node(&psNative->sListNode);
OSFreeMem(psNative);
}
dllist_remove_node(&psGroup->sListNode);
if (psGroup == _g_psRootGroup)
{
OSFreeMemNoStats(psGroup->pszName);
OSFreeMemNoStats(psGroup);
}
else
{
OSFreeMem(psGroup->pszName);
OSFreeMem(psGroup);
}
}
void *DIGetPrivData(const OSDI_IMPL_ENTRY *psEntry)
{
PVR_ASSERT(psEntry != NULL);
return psEntry->pvPrivData;
}
void DIWrite(const OSDI_IMPL_ENTRY *psEntry, const void *pvData,
IMG_UINT32 uiSize)
{
PVR_ASSERT(psEntry != NULL);
PVR_ASSERT(psEntry->psCb != NULL);
PVR_ASSERT(psEntry->psCb->pfnWrite != NULL);
PVR_ASSERT(psEntry->pvNative != NULL);
psEntry->psCb->pfnWrite(psEntry->pvNative, pvData, uiSize);
}
void DIPrintf(const OSDI_IMPL_ENTRY *psEntry, const IMG_CHAR *pszFmt, ...)
{
va_list args;
PVR_ASSERT(psEntry != NULL);
PVR_ASSERT(psEntry->psCb != NULL);
PVR_ASSERT(psEntry->psCb->pfnVPrintf != NULL);
PVR_ASSERT(psEntry->pvNative != NULL);
va_start(args, pszFmt);
psEntry->psCb->pfnVPrintf(psEntry->pvNative, pszFmt, args);
va_end(args);
}
void DIVPrintf(const OSDI_IMPL_ENTRY *psEntry, const IMG_CHAR *pszFmt,
va_list pArgs)
{
PVR_ASSERT(psEntry != NULL);
PVR_ASSERT(psEntry->psCb != NULL);
PVR_ASSERT(psEntry->psCb->pfnVPrintf != NULL);
PVR_ASSERT(psEntry->pvNative != NULL);
psEntry->psCb->pfnVPrintf(psEntry->pvNative, pszFmt, pArgs);
}
void DIPuts(const OSDI_IMPL_ENTRY *psEntry, const IMG_CHAR *pszStr)
{
PVR_ASSERT(psEntry != NULL);
PVR_ASSERT(psEntry->psCb != NULL);
PVR_ASSERT(psEntry->psCb->pfnPuts != NULL);
PVR_ASSERT(psEntry->pvNative != NULL);
psEntry->psCb->pfnPuts(psEntry->pvNative, pszStr);
}
IMG_BOOL DIHasOverflowed(const OSDI_IMPL_ENTRY *psEntry)
{
PVR_ASSERT(psEntry != NULL);
PVR_ASSERT(psEntry->psCb != NULL);
PVR_ASSERT(psEntry->psCb->pfnHasOverflowed != NULL);
PVR_ASSERT(psEntry->pvNative != NULL);
return psEntry->psCb->pfnHasOverflowed(psEntry->pvNative);
}
/* ---- OS implementation API ---------------------------------------------- */
static IMG_BOOL _ValidateImplCb(const OSDI_IMPL_CB *psImplCb)
{
PVR_GOTO_IF_FALSE(psImplCb->pfnInit != NULL, failed_);
PVR_GOTO_IF_FALSE(psImplCb->pfnDeInit != NULL, failed_);
PVR_GOTO_IF_FALSE(psImplCb->pfnCreateGroup != NULL, failed_);
PVR_GOTO_IF_FALSE(psImplCb->pfnDestroyGroup != NULL, failed_);
PVR_GOTO_IF_FALSE(psImplCb->pfnCreateEntry != NULL, failed_);
PVR_GOTO_IF_FALSE(psImplCb->pfnDestroyEntry != NULL, failed_);
return IMG_TRUE;
failed_:
return IMG_FALSE;
}
/* Walks the tree of groups and entries and create all of the native handles
* for the given implementation for all of the already existing groups and
* entries. */
static PVRSRV_ERROR _InitNativeHandlesRecursively(DI_IMPL *psImpl,
DI_GROUP *psGroup,
DI_NATIVE_HANDLE *psNativeParent)
{
PVRSRV_ERROR eError;
DLLIST_NODE *psThis, *psNext;
DI_NATIVE_HANDLE *psNativeGroup;
psNativeGroup = OSAllocMem(sizeof(*psNativeGroup));
PVR_LOG_RETURN_IF_NOMEM(psNativeGroup, "OSAllocMem");
eError = psImpl->sCb.pfnCreateGroup(psGroup->pszName,
psNativeParent ? psNativeParent->pvHandle : NULL,
&psNativeGroup->pvHandle);
PVR_LOG_GOTO_IF_ERROR(eError, "psImpl->sCb.pfnCreateGroup", free_memory_);
psNativeGroup->psDiImpl = psImpl;
dllist_add_to_head(&psGroup->sNativeHandleList,
&psNativeGroup->sListNode);
dllist_foreach_node(&psGroup->sGroupList, psThis, psNext)
{
DI_GROUP *psThisGroup = IMG_CONTAINER_OF(psThis, DI_GROUP, sListNode);
// and then walk the new group
eError = _InitNativeHandlesRecursively(psImpl, psThisGroup,
psNativeGroup);
PVR_LOG_RETURN_IF_ERROR(eError, "_InitNativeHandlesRecursively");
}
dllist_foreach_node(&psGroup->sEntryList, psThis, psNext)
{
DI_ENTRY *psThisEntry = IMG_CONTAINER_OF(psThis, DI_ENTRY, sListNode);
eError = _CreateNativeEntry(psThisEntry, psNativeGroup);
PVR_LOG_RETURN_IF_ERROR(eError, "_CreateNativeEntry");
}
return PVRSRV_OK;
free_memory_:
OSFreeMem(psNativeGroup);
return eError;
}
/* Walks the tree of groups and entries and destroys all of the native handles
* for the given implementation. */
static void _DeInitNativeHandlesRecursively(DI_IMPL *psImpl, DI_GROUP *psGroup)
{
DLLIST_NODE *psThis, *psNext;
dllist_foreach_node(&psGroup->sEntryList, psThis, psNext)
{
DI_ENTRY *psThisEntry = IMG_CONTAINER_OF(psThis, DI_ENTRY, sListNode);
DLLIST_NODE *psNativeThis, *psNativeNext;
// free all of the native entries that belong to this implementation
dllist_foreach_node(&psThisEntry->sNativeHandleList, psNativeThis, psNativeNext)
{
DI_NATIVE_HANDLE *psNativeEntry =
IMG_CONTAINER_OF(psNativeThis, DI_NATIVE_HANDLE, sListNode);
if (psNativeEntry->psDiImpl == psImpl)
{
_DestroyNativeEntry(psNativeEntry);
// there can be only one entry on the list for a given
// implementation
break;
}
}
}
dllist_foreach_node(&psGroup->sGroupList, psThis, psNext)
{
DI_GROUP *psThisGroup = IMG_CONTAINER_OF(psThis, DI_GROUP, sListNode);
// and then walk the new group
_DeInitNativeHandlesRecursively(psImpl, psThisGroup);
}
// free all of the native entries that belong to this implementation
dllist_foreach_node(&psGroup->sNativeHandleList, psThis, psNext)
{
DI_NATIVE_HANDLE *psNativeGroup =
IMG_CONTAINER_OF(psThis, DI_NATIVE_HANDLE, sListNode);
if (psNativeGroup->psDiImpl == psImpl)
{
_DestroyNativeGroup(psNativeGroup);
// there can be only one entry on the list for a given
// implementation
break;
}
}
}
static PVRSRV_ERROR _InitImpl(DI_IMPL *psImpl)
{
PVRSRV_ERROR eError;
// DI_NATIVE_HANDLE *psNativeGroup;
eError = psImpl->sCb.pfnInit();
PVR_LOG_GOTO_IF_ERROR(eError, "psImpl->pfnInit()", return_);
/* if the implementation is being created after any groups or entries
* have been created we need to walk the current tree and create
* native groups and entries for all of the existing ones */
eError = _InitNativeHandlesRecursively(psImpl, _g_psRootGroup, NULL);
PVR_LOG_GOTO_IF_ERROR(eError, "_InitNativeHandlesRecursively",
free_native_handles_and_deinit_);
psImpl->bInitialised = IMG_TRUE;
return PVRSRV_OK;
free_native_handles_and_deinit_:
/* something went wrong so we need to walk the tree and remove all of the
* native entries and groups that we've created before we can destroy
* the implementation */
_DeInitNativeHandlesRecursively(psImpl, _g_psRootGroup);
psImpl->sCb.pfnDeInit();
return_:
return eError;
}
PVRSRV_ERROR DIRegisterImplementation(const IMG_CHAR *pszName,
const OSDI_IMPL_CB *psImplCb)
{
DI_IMPL *psImpl;
PVRSRV_ERROR eError;
PVR_LOG_RETURN_IF_INVALID_PARAM(pszName != NULL, "pszName");
PVR_LOG_RETURN_IF_INVALID_PARAM(_ValidateImplCb(psImplCb), "psImplCb");
/* if root group does not exist it can mean 2 things:
* - DIInit() was not called so initialisation order is incorrect and needs
* to be fixed
* - DIInit() failed but if that happens we should never make it here */
PVR_ASSERT(_g_psRootGroup != NULL);
psImpl = OSAllocMem(sizeof(*psImpl));
PVR_LOG_RETURN_IF_NOMEM(psImpl, "OSAllocMem");
psImpl->pszName = pszName;
psImpl->sCb = *psImplCb;
OSLockAcquire(_g_hLock);
eError = _InitImpl(psImpl);
if (eError != PVRSRV_OK)
{
/* implementation could not be initialised so remove it from the
* list, free the memory and forget about it */
PVR_DPF((PVR_DBG_ERROR, "%s: could not initialise \"%s\" debug "
"info implementation, discarding", __func__,
psImpl->pszName));
goto free_impl_;
}
psImpl->bInitialised = IMG_TRUE;
dllist_add_to_tail(&_g_sImpls, &psImpl->sListNode);
OSLockRelease(_g_hLock);
return PVRSRV_OK;
free_impl_:
OSLockRelease(_g_hLock);
OSFreeMem(psImpl);
return eError;
}

View File

@@ -0,0 +1,220 @@
/*************************************************************************/ /*!
@File
@Title Functions for creating Debug Info groups and entries.
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef DI_SERVER_H
#define DI_SERVER_H
#if defined(__KERNEL__) && defined(__linux__)
#include <linux/version.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
#include <linux/stdarg.h>
#else
#include <stdarg.h>
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) */
#else
#include <stdarg.h>
#endif /* __KERNEL__ && __linux__ */
#include "di_common.h"
#include "pvrsrv_error.h"
#include "img_defs.h"
/*! @Function DIInit
*
* @Description
* Initialises Debug Info framework. This function will create common resources
* for the framework.
*
* Note: This function must be called before first call to
* DIRegisterImplementation() all of the implementations.
*/
PVRSRV_ERROR DIInit(void);
/*! @Function DIDeInit
*
* @Description
* De-initialises Debug Info framework. This function will call pfnDeInit()
* on each implementation and clean up common resources.
*
* In case some of the entries and groups have not been cleaned up this function
* will also perform recursive sweep and remove all entries and group for
* all implementations.
*/
void DIDeInit(void);
/*! @Function DICreateEntry
*
* @Description
* Creates debug info entry. Depending on different implementations the entry
* might be for example a DebugFS file or something totally different.
*
* The entry will belong to a parent group if provided or to the root group
* if not.
*
* @Input pszName: name of the new entry
* @Input psDiGroup: parent group, if NULL entry will belong to the root group
* @Input psIterCb: implementation of the iterator for the entry
* @Input psPriv: private data that will be passed to the iterator operations
* @Input eType: type of the entry
*
* @Output ppsEntry: handle to the newly created entry
*
* @Return PVRSRV_ERROR error code
*/
PVRSRV_ERROR DICreateEntry(const IMG_CHAR *pszName,
DI_GROUP *psGroup,
const DI_ITERATOR_CB *psIterCb,
void *psPriv,
DI_ENTRY_TYPE eType,
DI_ENTRY **ppsEntry);
/*! @Function DIDestroyEntry
*
* @Description
* Destroys debug info entry.
*
* @Input psEntry: handle to the entry
*/
void DIDestroyEntry(DI_ENTRY *psEntry);
/*! @Function DICreateGroup
*
* @Description
* Creates debug info group. Depending on different implementations the group
* might be for example a DebugFS directory or something totally different.
*
* The group will belong to a parent group if provided or to the root group
* if not.
*
* @Input pszName: name of the new entry
* @Input psParent: parent group, if NULL entry will belong to the root group
*
* @Output ppsGroup: handle to the newly created entry
*
* @Return PVRSRV_ERROR error code
*/
PVRSRV_ERROR DICreateGroup(const IMG_CHAR *pszName,
DI_GROUP *psParent,
DI_GROUP **ppsGroup);
/*! @Function DIDestroyGroup
*
* @Description
* Destroys debug info group.
*
* @Input psGroup: handle to the group
*/
void DIDestroyGroup(DI_GROUP *psGroup);
/*! @Function DIGetPrivData
*
* @Description
* Retrieves private data from psEntry. The data is either passed during
* entry creation via psPriv parameter of DICreateEntry() function
* or by explicitly setting it with DIGetPrivData() function.
*
* @Input psEntry pointer to OSDI_IMPL_ENTRY object
*
* @Returns pointer to the private data (can be NULL if private data
* has not been specified)
*/
void *DIGetPrivData(const OSDI_IMPL_ENTRY *psEntry);
/*! @Function DIWrite
*
* @Description
* Writes the binary data of the DI entry to the output sync, whatever that may
* be for the DI implementation.
*
* @Input psEntry pointer to OSDI_IMPL_ENTRY object
* @Input pvData data
* @Input uiSize pvData length
*/
void DIWrite(const OSDI_IMPL_ENTRY *psEntry, const void *pvData,
IMG_UINT32 uiSize);
/*! @Function DIPrintf
*
* @Description
* Prints formatted string to the DI entry.
*
* @Input psEntry pointer to OSDI_IMPL_ENTRY object
* @Input pszFmt NUL-terminated format string
*/
__printf(2, 3)
void DIPrintf(const OSDI_IMPL_ENTRY *psEntry, const IMG_CHAR *pszFmt, ...);
/*! @Function DIVPrintf
*
* @Description
* Prints formatted string to the DI entry. Equivalent to DIPrintf but takes
* va_list instead of a variable number of arguments.
*
* @Input psEntry pointer to OSDI_IMPL_ENTRY object
* @Input pszFmt NUL-terminated format string
* @Input pArgs vs_list object
*/
__printf(2, 0)
void DIVPrintf(const OSDI_IMPL_ENTRY *psEntry, const IMG_CHAR *pszFmt,
va_list pArgs);
/*! @Function DIPrintf
*
* @Description
* Prints a string to the DI entry.
*
* @Input psEntry pointer to OSDI_IMPL_ENTRY object
* @Input pszFmt NUL-terminated string
*/
void DIPuts(const OSDI_IMPL_ENTRY *psEntry, const IMG_CHAR *pszStr);
/*! @Function DIHasOverflowed
*
* @Description
* Checks if the DI buffer has overflowed.
*
* @Return IMG_TRUE if buffer overflowed
*/
IMG_BOOL DIHasOverflowed(const OSDI_IMPL_ENTRY *psEntry);
#endif /* DI_SERVER_H */

View File

@@ -0,0 +1,409 @@
/*************************************************************************/ /*!
@File dkf_server.c
@Title DRM Key Framework support routines.
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#include "dkf_server.h"
#include "img_types.h"
#include "device.h"
#include "pvrsrv_error.h"
#include "dkp_impl.h"
#include "osfunc.h"
#include "pvr_debug.h"
#if defined(SUPPORT_LINUX_FDINFO)
typedef struct DKF_REGISTERED_DKP_TAG
{
IMG_HANDLE hPrivHandle; /*!< Private data - can be NULL */
const IMG_CHAR *pszDKPName; /*!< DKP provider name */
IMG_PID pid; /*!< Process-ID - can be 0 */
IMG_UINT32 uiReserved1; /*!< Reserved field - padding */
DKP_PFN_SHOW *psDKPShowPfn; /*!< DKP Callback function */
DLLIST_NODE sDKFEntryNode; /*!< List of DKP entries */
DKP_CONNECTION_FLAGS ui32Filter; /*!< The types of connection to output to */
} DKF_REGISTERED_DKP;
/* Global sentinel to track all allocated DKP callback key/value pairs */
typedef struct DKF_TAG
{
POS_LOCK hDKFListLock; /*!< Lock for accessing sDKFListNode */
IMG_UINT32 ui32NumEntries; /*!< Number of registered DKP entries */
IMG_UINT32 uiReserved1; /*!< Reserved field - padding */
DLLIST_NODE sDKFListNode; /*!< Head of the DKF_REGISTERED_DKP linked list */
DKF_VPRINTF_FUNC *pfnPrint; /*!< Default printf-style output fn */
void *pvPrintArg1; /*!< First arg for pfnPrint */
} DKF;
static DKF *gpsDKF;
static_assert(DKF_CONNECTION_FLAG_INVALID == DKP_CONNECTION_FLAG_INVALID, "DKF and DKP INVALID connection flags do not match");
static_assert(DKF_CONNECTION_FLAG_SYNC == DKP_CONNECTION_FLAG_SYNC, "DKF and DKP SYNC connection flags do not match");
static_assert(DKF_CONNECTION_FLAG_SERVICES == DKP_CONNECTION_FLAG_SERVICES, "DKF and DKP SERVICES connection flags do not match");
PVRSRV_ERROR PVRDKFInit(void)
{
DKF *psDKF;
PVRSRV_ERROR eError = PVRSRV_ERROR_OUT_OF_MEMORY;
if (gpsDKF != NULL)
{
PVR_DPF((PVR_DBG_WARNING, "%s: gpsDKF = %p, NULL expected",
__func__, gpsDKF));
return PVRSRV_OK;
}
PVR_DPF((PVR_DBG_MESSAGE, "%s called", __func__));
psDKF = OSAllocZMemNoStats(sizeof(*psDKF));
PVR_GOTO_IF_NOMEM(psDKF, eError, Error);
dllist_init(&psDKF->sDKFListNode);
eError = OSLockCreate(&psDKF->hDKFListLock);
PVR_GOTO_IF_ERROR(eError, ErrorFree);
gpsDKF = psDKF;
return PVRSRV_OK;
ErrorFree:
OSFreeMemNoStats(psDKF);
/* fallthrough */
Error:
PVR_DPF((PVR_DBG_ERROR, "%s: %s", __func__, PVRSRVGetErrorString(eError)));
return eError;
}
void PVRDKFDeInit(void)
{
IMG_UINT32 uiNumFreed = 0U;
PVR_DPF((PVR_DBG_MESSAGE, "%s called", __func__));
if (gpsDKF == NULL)
{
return;
}
/* Ensure we leave no data allocated. The DKP instances should have
* been cleaned up by their module deInit processing. Handle badly
* behaved clients here.
*/
if (gpsDKF->ui32NumEntries > 0)
{
DLLIST_NODE *psThis, *psNext;
PVR_DPF((PVR_DBG_ERROR,
"%s: Have %u un-freed allocations remaining", __func__,
gpsDKF->ui32NumEntries));
OSLockAcquire(gpsDKF->hDKFListLock);
dllist_foreach_node(&gpsDKF->sDKFListNode, psThis, psNext)
{
DKF_REGISTERED_DKP *psEntry = IMG_CONTAINER_OF(psThis,
DKF_REGISTERED_DKP,
sDKFEntryNode);
dllist_remove_node(&psEntry->sDKFEntryNode);
uiNumFreed++;
OSFreeMemNoStats(psEntry);
}
if (uiNumFreed != gpsDKF->ui32NumEntries)
{
PVR_DPF((PVR_DBG_ERROR, "Could only free %u out of %u",
uiNumFreed, gpsDKF->ui32NumEntries));
}
dllist_remove_node(&gpsDKF->sDKFListNode);
OSLockRelease(gpsDKF->hDKFListLock);
}
OSLockDestroy(gpsDKF->hDKFListLock);
OSFreeMemNoStats(gpsDKF);
gpsDKF = NULL;
}
void PVRDKFTraverse(DKF_VPRINTF_FUNC *pfnPrint,
void *pvArg,
struct _PVRSRV_DEVICE_NODE_ *psDevNode,
IMG_PID pid,
DKF_CONNECTION_FLAGS ui32ConnectionType)
{
PDLLIST_NODE pNext, pNode;
PVR_ASSERT(gpsDKF != NULL);
PVR_ASSERT(pfnPrint != NULL);
PVR_ASSERT(ui32ConnectionType != DKF_CONNECTION_FLAG_INVALID);
OSLockAcquire(gpsDKF->hDKFListLock);
gpsDKF->pfnPrint = pfnPrint;
gpsDKF->pvPrintArg1 = pvArg;
if (dllist_is_empty(&gpsDKF->sDKFListNode))
{
PVR_DPF((PVR_DBG_WARNING, "%s: No DKPs registered", __func__));
}
else
{
dllist_foreach_node(&gpsDKF->sDKFListNode, pNode, pNext)
{
DKF_REGISTERED_DKP *psEntry = IMG_CONTAINER_OF(pNode,
DKF_REGISTERED_DKP,
sDKFEntryNode);
if (psEntry->psDKPShowPfn != NULL &&
BITMASK_ANY(psEntry->ui32Filter, ui32ConnectionType))
{
psEntry->psDKPShowPfn(psDevNode, pid,
psEntry->hPrivHandle);
}
}
}
OSLockRelease(gpsDKF->hDKFListLock);
}
/*
* Wrapper function to display data using preconfigured DKF-specific output
* function.
*/
void PVRDKPOutput(IMG_HANDLE hPrivData, const char *fmt, ...)
{
DKF_REGISTERED_DKP *psDKFEntry = (DKF_REGISTERED_DKP *)hPrivData;
IMG_CHAR szBuffer[PVR_MAX_DEBUG_MESSAGE_LEN];
va_list Arglist;
DLLIST_NODE *pNode, *pNext;
IMG_BOOL bFound = IMG_FALSE;
if (psDKFEntry == NULL || gpsDKF == NULL)
{
PVR_DPF((PVR_DBG_WARNING, "%s: NULL DKF entry found (%p, %p)",
__func__, psDKFEntry, gpsDKF));
return;
}
PVR_ASSERT(gpsDKF->pfnPrint != NULL);
/* validate that this is a legitimate output function reference */
dllist_foreach_node(&gpsDKF->sDKFListNode, pNode, pNext)
{
DKF_REGISTERED_DKP *psEntry = IMG_CONTAINER_OF(pNode,
DKF_REGISTERED_DKP,
sDKFEntryNode);
if (psEntry == psDKFEntry)
{
bFound = IMG_TRUE;
break;
}
}
if (!bFound)
{
PVR_DPF((PVR_DBG_WARNING, "%s: Handle %p not found.", __func__,
hPrivData));
return;
}
OSSNPrintf(szBuffer, PVR_MAX_DEBUG_MESSAGE_LEN, "%s", fmt);
va_start(Arglist, fmt);
gpsDKF->pfnPrint(gpsDKF->pvPrintArg1, szBuffer, &Arglist);
va_end(Arglist);
}
PVRSRV_ERROR PVRSRVRegisterDKP(IMG_HANDLE hPrivData,
const char *pszDKPName,
DKP_PFN_SHOW *psShowPfn,
DKP_CONNECTION_FLAGS ui32Filter,
PPVRDKF_DKP_HANDLE phDkpHandle)
{
DKF_REGISTERED_DKP *psDKFEntry; /* New entry for this DKP */
PVRSRV_ERROR eError = PVRSRV_ERROR_OUT_OF_MEMORY;
/* Check for a NULL argument. Nothing to allocate if we are not provided
* a location to store the DkpHandle reference.
*/
if (phDkpHandle == NULL || ui32Filter == DKF_CONNECTION_FLAG_INVALID)
{
#if defined(DEBUG)
PVR_DPF((PVR_DBG_WARNING, "%s(%p, %s, %p, %p) Called", __func__,
hPrivData, pszDKPName, psShowPfn,
phDkpHandle));
#endif
return PVRSRV_ERROR_INVALID_PARAMS;
}
psDKFEntry = OSAllocZMemNoStats(sizeof(*psDKFEntry));
PVR_GOTO_IF_NOMEM(psDKFEntry, eError, Error);
OSLockAcquire(gpsDKF->hDKFListLock);
psDKFEntry->hPrivHandle = hPrivData;
psDKFEntry->pszDKPName = pszDKPName;
psDKFEntry->psDKPShowPfn = psShowPfn;
psDKFEntry->ui32Filter = ui32Filter;
dllist_init(&psDKFEntry->sDKFEntryNode);
/*
* Append the new entry to the end of the gpsDKF list-head. Return a
* reference to the new entry to the caller.
*/
dllist_add_to_tail(&gpsDKF->sDKFListNode, &psDKFEntry->sDKFEntryNode);
gpsDKF->ui32NumEntries++;
OSLockRelease(gpsDKF->hDKFListLock);
*phDkpHandle = psDKFEntry;
return PVRSRV_OK;
Error:
PVR_DPF((PVR_DBG_ERROR, "%s: Error: '%s'", __func__,
PVRSRVGetErrorString(eError)));
return eError;
}
PVRSRV_ERROR PVRSRVUnRegisterDKP(IMG_HANDLE hPrivData, PVRDKF_DKP_HANDLE hDkpHandle)
{
DKF_REGISTERED_DKP *psDKFEntry = (DKF_REGISTERED_DKP *)hDkpHandle;
PVRSRV_ERROR eError = PVRSRV_OK;
if (psDKFEntry)
{
#if defined(DEBUG)
if (psDKFEntry->hPrivHandle == hPrivData)
{
PVR_DPF((PVR_DBG_VERBOSE, "%s: Matched %p private handle",
__func__, hDkpHandle));
}
else
{
PVR_DPF((PVR_DBG_VERBOSE,
"%s: Did not find match (%p. vs %p), freeing anyway",
__func__, hPrivData, psDKFEntry->hPrivHandle));
}
#endif /* DEBUG */
OSLockAcquire(gpsDKF->hDKFListLock);
dllist_remove_node(&psDKFEntry->sDKFEntryNode);
gpsDKF->ui32NumEntries--;
OSLockRelease(gpsDKF->hDKFListLock);
OSFreeMemNoStats(psDKFEntry);
}
else
{
eError = PVRSRV_ERROR_INVALID_PARAMS;
}
return eError;
}
#else
/* Stub routines for earlier kernel versions */
PVRSRV_ERROR PVRDKFInit(void)
{
return PVRSRV_OK;
}
void PVRDKFDeInit(void)
{
}
void PVRDKFTraverse(DKF_VPRINTF_FUNC *pfnPrint,
void *pvArg,
struct _PVRSRV_DEVICE_NODE_ *psDevNode,
IMG_PID pid,
IMG_UINT32 ui32ConnectionType)
{
PVR_UNREFERENCED_PARAMETER(psDevNode);
PVR_UNREFERENCED_PARAMETER(pid);
}
void PVRDKPOutput(IMG_HANDLE hPrivData, const char *fmt, ...)
{
PVR_UNREFERENCED_PARAMETER(hPrivData);
PVR_UNREFERENCED_PARAMETER(fmt);
}
PVRSRV_ERROR PVRSRVRegisterDKP(IMG_HANDLE hPrivData, const char *pszDKPName,
DKP_PFN_SHOW *psShowPfn,
DKP_CONNECTION_FLAGS ui32Filter,
PPVRDKF_DKP_HANDLE phDkpHandle)
{
PVR_UNREFERENCED_PARAMETER(hPrivData);
PVR_UNREFERENCED_PARAMETER(pszDKPName);
PVR_UNREFERENCED_PARAMETER(psShowPfn);
PVR_UNREFERENCED_PARAMETER(phDkpHandle);
return PVRSRV_OK;
}
PVRSRV_ERROR PVRSRVUnRegisterDKP(IMG_HANDLE hPrivData, PVRDKF_DKP_HANDLE hDkpHandle)
{
PVR_UNREFERENCED_PARAMETER(hPrivData);
PVR_UNREFERENCED_PARAMETER(hDkpHandle);
return PVRSRV_OK;
}
#endif /* SUPPORT_LINUX_FDINFO */

View File

@@ -0,0 +1,103 @@
/**************************************************************************/ /*!
@File dkf_server.h
@Title Functions for supporting the DRM Key Framework
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /***************************************************************************/
#if !defined(DKF_SERVER_H)
#define DKF_SERVER_H
#include "img_types.h"
#include "pvrsrv_error.h"
#if defined(SUPPORT_LINUX_FDINFO)
#include <drm/drm_print.h>
typedef void (DKF_VPRINTF_FUNC)(struct drm_printer *p, const char *fmt, va_list *va) __printf(2, 0);
#else /* !defined(SUPPORT_LINUX_FDINFO) */
typedef void (DKF_VPRINTF_FUNC)(void *p, const char *fmt, ...) __printf(2, 3);
#endif /* defined(SUPPORT_LINUX_FDINFO) */
struct _PVRSRV_DEVICE_NODE_;
typedef IMG_UINT32 DKF_CONNECTION_FLAGS;
#define DKF_CONNECTION_FLAG_SYNC BIT(0)
#define DKF_CONNECTION_FLAG_SERVICES BIT(1)
#define DKF_CONNECTION_FLAG_INVALID IMG_UINT32_C(0)
/*! @Function PVRDKFTraverse
*
* @Description
* Outputs the DKP data associated with the given device node's
* framework entries.
*
* @Input pfnPrint The print function callback to be used to output.
* @Input pvArg Print function first argument.
* @Input psDevNode Device node associated with fdinfo owner.
* @Input pid Process ID of the process owning the FD the fdinfo
* file relates to.
* @Input ui32ConnectionType A value indicating the PVR connection type
* (sync or services).
*/
void PVRDKFTraverse(DKF_VPRINTF_FUNC *pfnPrint,
void *pvArg,
struct _PVRSRV_DEVICE_NODE_ *psDevNode,
IMG_PID pid,
DKF_CONNECTION_FLAGS ui32ConnectionType);
/* @Function PVRDKFInit
*
* @Description
* Initialises the DKF infrastructure for subsequent usage by the PVR system.
*
* @Returns PVRSRV_ERROR.
*/
PVRSRV_ERROR PVRDKFInit(void);
/* @Function PVRDKFDeInit
*
* @Description
* Removes and frees all associated system-specific DKF meta-data.
*/
void PVRDKFDeInit(void);
#endif

View File

@@ -0,0 +1,163 @@
/**************************************************************************/ /*!
@File dkp_impl.h
@Title Functions for supporting the DRM Key Provider
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /***************************************************************************/
#ifndef DKP_IMPL_H
#define DKP_IMPL_H
typedef IMG_HANDLE PVRDKF_DKP_HANDLE;
typedef PVRDKF_DKP_HANDLE * PPVRDKF_DKP_HANDLE;
/*! @Function DKP_PFN_SHOW
*
* @Description
*
* Describes the function called by the DKF infrastructure to request the DKP
* outputs all the mandatory and optional keys it supports. Each
* key / value pair should be output one per line using the provided
* PVRDPFOutput routine.
*
* The function should check that the passed 'psDevNode' references the
* same device as that associated with the module-specific 'hPrivData' handle.
* If it doesn't, no data should be displayed.
*
* @Input psDevNode Pointer to device node for which data must be shown.
* @Input pid Process-ID for which data must be shown.
* @Input hPrivData Private data passed to DKF from DKP_Register. The DKP
* must use this within calls to the DKP_PFN_SHOW to limit
* the data key/value pairs to only those that are relevant
* to this instance.
*/
typedef void (DKP_PFN_SHOW)(struct _PVRSRV_DEVICE_NODE_ *psDevNode, int pid,
IMG_HANDLE hPrivData);
typedef IMG_UINT32 DKP_CONNECTION_FLAGS;
#define DKP_CONNECTION_FLAG_SYNC BIT(0)
#define DKP_CONNECTION_FLAG_SERVICES BIT(1)
#define DKP_CONNECTION_FLAG_INVALID IMG_UINT32_C(0)
#define DKP_CONNECTION_FLAG_ALL (DKP_CONNECTION_FLAG_SYNC | DKP_CONNECTION_FLAG_SERVICES)
/* @Function PVRSRVRegisterDKP
*
* @Description
* Registers a DKP with the specified module's DKF entry.
*
* @Input hPrivData DKP Private data handle that the DKF will pass into
* the ShowPFN when called. Can be NULL if there is no
* DKP instance private data.
* @Input pszDKPName Provider name associated with the caller.
* @Input psShowPfn Function to be used when the fdinfo statistics
* are queried.
* @Input ui32Filter The connection types this DKP should be output
* on.
* @Output phDkpHandle Location to store generated handle created by this
* function.
*
* @Returns PVRSRV_ERROR
*/
PVRSRV_ERROR PVRSRVRegisterDKP(IMG_HANDLE hPrivData,
const char *pszDKPName,
DKP_PFN_SHOW *psShowPfn,
DKP_CONNECTION_FLAGS ui32Filter,
PPVRDKF_DKP_HANDLE phDkpHandle);
/* @Function PVRSRVUnRegisterDKP
*
* @Description
* Removes a previously registered key from the device's DKF entry.
*
* @Input hPrivData Private data handle.
* @Input hDkpHandle Handle to the DKP's registered entry.
* Obtained from earlier PVRSRV_DKP_Register call.
*
* @Returns PVRSRV_ERROR
*/
PVRSRV_ERROR PVRSRVUnRegisterDKP(IMG_HANDLE hPrivData,
PVRDKF_DKP_HANDLE hDkpHandle);
/* @Function PVRDKPOutput
* Wrapper function which passes the printf-style arguments to the registered
* DKF output function associated with the registered DKP handle.
*
* @Input hPrivData Handle for associated DKP instance producing the output.
* @Input fmt printf-style format string
*
*/
void PVRDKPOutput(IMG_HANDLE hPrivData, const char *fmt, ...) __printf(2, 3);
#if !defined(__linux__) || defined(INTEGRITY_OS) || defined(__QNXNTO__)
/* Stub routines follow */
static inline PVRSRV_ERROR PVRSRVRegisterDKP(IMG_HANDLE hPrivData,
const char *pszDKPName,
DKP_PFN_SHOW *psShowPfn,
DKP_CONNECTION_FLAGS ui32Filter,
PPVRDKF_DKP_HANDLE phDkpHandle)
{
PVR_UNREFERENCED_PARAMETER(hPrivData);
PVR_UNREFERENCED_PARAMETER(pszDKPName);
PVR_UNREFERENCED_PARAMETER(psShowPfn);
PVR_UNREFERENCED_PARAMETER(phDkpHandle);
return PVRSRV_ERROR_NOT_SUPPORTED;
}
static inline PVRSRV_ERROR PVRSRVUnRegisterDKP(IMG_HANDLE hPrivData,
PVRDKF_DKP_HANDLE hDkpHandle)
{
PVR_UNREFERENCED_PARAMETER(hPrivData);
PVR_UNREFERENCED_PARAMETER(hDkpHandle);
return PVRSRV_ERROR_NOT_SUPPORTED;
}
static inline void PVRDKPOutput(IMG_HANDLE hPrivData, const char *fmt, ...) __printf(2, 3)
{
PVR_UNREFERENCED_PARAMETER(hPrivData);
PVR_UNREFERENCED_PARAMETER(fmt);
}
#endif /* !__linux__ || INTEGRITY_OS || __QNXNTO__ */
#endif /* DKP_IMPL_H */

View File

@@ -0,0 +1,455 @@
/*************************************************************************/ /*!
@File
@Title Double linked list header
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Double linked list interface
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef DLLIST_H
#define DLLIST_H
#include "img_types.h"
#include "img_defs.h"
/*!
Pointer to a linked list node
*/
typedef struct DLLIST_NODE_TAG *PDLLIST_NODE;
/*!
Node in a linked list.
A list is comprised of a single list head and 0 to n nodes.
The head and nodes are all represented by `DLLIST_NODE`'s.
The head node is a special sentinel and should not be associated with
any elements in the list.
For example, the following list of fruits has 3 elements:
`... <--> "banana" <--> "apple" <--> head <--> "orange" <--> ...`
Therefore, using dllist_foreach_*(head) will iterate just the 3 fruits.
This is important because a `dllist_is_empty` is when the number of
elements == 0 is equivalent to when the head points to itself.
Proper use of the dllist_* functions requires a head.
For example, the following list is improper:
`... <--> "banana" <--> "apple" <--> "orange" <--> ...`
as one element must be treated as the head, and therefore is ignored.
*/
/*
* Note: the following structure's size is architecture-dependent and clients
* may need to create a mirror of the structure definition if it needs to be
* used in a structure shared between host and device.
* Consider such clients if any changes are made to this structure.
*/
typedef struct DLLIST_NODE_TAG
{
struct DLLIST_NODE_TAG *psPrevNode;
struct DLLIST_NODE_TAG *psNextNode;
} DLLIST_NODE;
/*!
Static initialiser
*/
#define DECLARE_DLLIST(n) \
DLLIST_NODE (n) = {&(n), &(n)}
/*************************************************************************/ /*!
@Function dllist_foreach_node
@Description Walk through all the nodes on the list.
Safe against removal of (node).
@Input list_head List node to start the operation
@Input node Current list node
@Input next Node after the current one
*/
/*****************************************************************************/
#define dllist_foreach_node(list_head, node, next) \
for ((node) = (list_head)->psNextNode, (next) = (node)->psNextNode; \
(node) != (list_head); \
(node) = (next), (next) = (node)->psNextNode)
#define dllist_foreach_node_backwards(list_head, node, prev) \
for ((node) = (list_head)->psPrevNode, (prev) = (node)->psPrevNode; \
(node) != (list_head); \
(node) = (prev), (prev) = (node)->psPrevNode)
/*************************************************************************/ /*!
@Function dllist_foreach
@Description Simplification of dllist_foreach_node.
Walk through all the nodes on the list.
Safe against removal of currently-iterated node.
Adds utility-macro dllist_cur() to typecast the current node.
@Input list_head List node to start the operation
*/
/*****************************************************************************/
#define dllist_foreach(list_head) \
for (DLLIST_NODE *DllCurNode = (list_head).psNextNode, *DllNextNode = DllCurNode->psNextNode; \
DllCurNode != &(list_head); \
DllCurNode = DllNextNode, DllNextNode = DllCurNode->psNextNode)
#define dllist_foreach_backwards(list_head) \
for (DLLIST_NODE *DllCurNode = (list_head).psPrevNode, *DllPrevNode = DllCurNode->psPrevNode; \
DllCurNode != &(list_head); \
DllCurNode = DllPrevNode, DllPrevNode = DllCurNode->psPrevNode)
#define dllist_cur(type, member) IMG_CONTAINER_OF(DllCurNode, type, member)
/*************************************************************************/ /*!
@Function dllist_init
@Description Initialize a new double linked list
@Input psListHead List head Node
*/
/*****************************************************************************/
static INLINE
void dllist_init(PDLLIST_NODE psListHead)
{
psListHead->psPrevNode = psListHead;
psListHead->psNextNode = psListHead;
}
/*************************************************************************/ /*!
@Function dllist_is_empty
@Description Returns whether the list is empty
@Input psListHead List head Node
*/
/*****************************************************************************/
static INLINE
bool dllist_is_empty(const DLLIST_NODE *const psListHead)
{
return (psListHead->psPrevNode == psListHead);
}
/*************************************************************************/ /*!
@Function dllist_add_to_head
@Description Add psNewNode to head of list psListHead
@Input psListHead Head Node
@Input psNewNode New Node
*/
/*****************************************************************************/
static INLINE
void dllist_add_to_head(PDLLIST_NODE psListHead, PDLLIST_NODE psNewNode)
{
PDLLIST_NODE psTmp;
psTmp = psListHead->psNextNode;
psListHead->psNextNode = psNewNode;
psNewNode->psNextNode = psTmp;
psTmp->psPrevNode = psNewNode;
psNewNode->psPrevNode = psListHead;
}
/*************************************************************************/ /*!
@Function dllist_add_to_tail
@Description Add psNewNode to tail of list psListHead
@Input psListHead Head Node
@Input psNewNode New Node
*/
/*****************************************************************************/
static INLINE
void dllist_add_to_tail(PDLLIST_NODE psListHead, PDLLIST_NODE psNewNode)
{
PDLLIST_NODE psTmp;
psTmp = psListHead->psPrevNode;
psListHead->psPrevNode = psNewNode;
psNewNode->psPrevNode = psTmp;
psTmp->psNextNode = psNewNode;
psNewNode->psNextNode = psListHead;
}
/*************************************************************************/ /*!
@Function dllist_node_is_in_list
@Description Returns true if psNode is in a list
@Input psNode List node
*/
/*****************************************************************************/
static INLINE
bool dllist_node_is_in_list(const DLLIST_NODE *const psNode)
{
return (psNode->psNextNode != NULL);
}
/*************************************************************************/ /*!
@Function dllist_get_next_node
@Description Returns the list node after psListHead or NULL psListHead is
the only element in the list.
@Input psListHead List node to start the operation
*/
/*****************************************************************************/
static INLINE
PDLLIST_NODE dllist_get_next_node(PDLLIST_NODE psListHead)
{
if (psListHead->psNextNode == psListHead)
{
return NULL;
}
else
{
return psListHead->psNextNode;
}
}
/*************************************************************************/ /*!
@Function dllist_get_prev_node
@Description Returns the list node preceding psListHead or NULL if
psListHead is the only element in the list.
@Input psListHead List node to start the operation
*/
/*****************************************************************************/
static INLINE
PDLLIST_NODE dllist_get_prev_node(PDLLIST_NODE psListHead)
{
if (psListHead->psPrevNode == psListHead)
{
return NULL;
}
else
{
return psListHead->psPrevNode;
}
}
/*************************************************************************/ /*!
@Function dllist_remove_node
@Description Removes psListNode from the list where it currently belongs
@Input psListNode List node to be removed
*/
/*****************************************************************************/
static INLINE
void dllist_remove_node(PDLLIST_NODE psListNode)
{
psListNode->psNextNode->psPrevNode = psListNode->psPrevNode;
psListNode->psPrevNode->psNextNode = psListNode->psNextNode;
/* Clear the node to show it's not in a list */
psListNode->psPrevNode = NULL;
psListNode->psNextNode = NULL;
}
/*************************************************************************/ /*!
@Function dllist_replace_head
@Description Moves the list from psOldHead to psNewHead
@Input psOldHead List node to be replaced. Will become a
head node of an empty list.
@Input psNewHead List node to be inserted. Must be an
empty list head.
*/
/*****************************************************************************/
static INLINE
void dllist_replace_head(PDLLIST_NODE psOldHead, PDLLIST_NODE psNewHead)
{
if (dllist_is_empty(psOldHead))
{
psNewHead->psNextNode = psNewHead;
psNewHead->psPrevNode = psNewHead;
}
else
{
/* Change the neighbouring nodes */
psOldHead->psNextNode->psPrevNode = psNewHead;
psOldHead->psPrevNode->psNextNode = psNewHead;
/* Copy the old data to the new node */
psNewHead->psNextNode = psOldHead->psNextNode;
psNewHead->psPrevNode = psOldHead->psPrevNode;
/* Remove links to the previous list */
psOldHead->psNextNode = psOldHead;
psOldHead->psPrevNode = psOldHead;
}
}
/**************************************************************************/ /*!
@Function dllist_insert_list_at_head
@Description Inserts psInHead list into the head of the psOutHead list.
After this operation psOutHead will contain psInHead at the
head of the list and the remaining elements that were
already in psOutHead will be places after the psInList (so
at a tail of the original list).
@Input psOutHead List node psInHead will be inserted to.
@Input psInHead List node to be inserted to psOutHead.
After this operation this becomes an empty list.
*/ /***************************************************************************/
static INLINE
void dllist_insert_list_at_head(PDLLIST_NODE psOutHead, PDLLIST_NODE psInHead)
{
PDLLIST_NODE psInHeadNextNode = psInHead->psNextNode;
PDLLIST_NODE psOutHeadNextNode = psOutHead->psNextNode;
if (!dllist_is_empty(psInHead))
{
psOutHead->psNextNode = psInHeadNextNode;
psInHeadNextNode->psPrevNode = psOutHead;
psInHead->psPrevNode->psNextNode = psOutHeadNextNode;
psOutHeadNextNode->psPrevNode = psInHead->psPrevNode;
dllist_init(psInHead);
}
}
/*************************************************************************/ /*!
@Description Pointer to a dllist comparison callback function.
@Input psNode Pointer to a node in a dllist.
@Input psNext Pointer to psNode's next neighbour.
*/ /**************************************************************************/
typedef bool (*DLLIST_CMP_CB)(const DLLIST_NODE *psNode, const DLLIST_NODE *psNext);
/*************************************************************************/ /*!
@Function dllist_sort
@Description Insert-sorts the List in place
The cmpr function passes the current and next node,
From which the user writes the function responsible
for choosing to swap order or not.
The function returns true if a swap is required
@Input psListHead List Head to be sorted.
@Input cmpr Function pointer to use for sorting
*/
/*****************************************************************************/
static INLINE void dllist_sort(PDLLIST_NODE psListHead,
DLLIST_CMP_CB cmpr)
{
DLLIST_NODE *node, *next;
DLLIST_NODE sTempHead;
dllist_init(&sTempHead);
dllist_foreach_node(psListHead, node, next)
{
dllist_remove_node(node);
dllist_add_to_head(&sTempHead, node);
}
while (!dllist_is_empty(&sTempHead))
{
DLLIST_NODE *psSmallestNode = NULL;
dllist_foreach_node(&sTempHead, node, next)
{
if (!psSmallestNode || cmpr(psSmallestNode, node))
{
psSmallestNode = node;
}
}
dllist_remove_node(psSmallestNode);
dllist_add_to_tail(psListHead, psSmallestNode);
}
}
/*************************************************************************/ /*!
@Function dllist_split
@Description Split the list at psNode from psOldHead and place in psNewHead
After the operation completes psNewHead will contain a list
starting at psNode and psOldHead will have psNode->prevNode as
its tail element (i.e.,
psOldHead->psPrevNode = psNode->prevNode, and the new tail
(psNode->prevNode->nextNode = psOldHead)).
@Input psNode List split-point.
@Input psOldHead List head to remove psNode and remaining
nodes from.
@Input psNewHead List head to receive new list
*/
/*****************************************************************************/
static INLINE void dllist_split(PDLLIST_NODE psNode, PDLLIST_NODE psOldHead,
PDLLIST_NODE psNewHead)
{
PDLLIST_NODE psPrevNode = psNode->psPrevNode;
PDLLIST_NODE psCurTail = psOldHead->psPrevNode;
/* Split the list and move psNode ... psCurTail to psNewHead */
psNewHead->psPrevNode = psCurTail;
psNode->psPrevNode = psNewHead;
psCurTail->psNextNode = psNewHead;
psNewHead->psNextNode = psNode;
/* Now update the psOldHead tail pointer and psCurTail links */
psOldHead->psPrevNode = psPrevNode;
psPrevNode->psNextNode = psOldHead;
}
#endif /* DLLIST_H */

View File

@@ -0,0 +1,85 @@
/*************************************************************************/ /*!
@File dma_km.h
@Title DMA transfer module header
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef DMA_KM_H
#define DMA_KM_H
#if defined(__linux__)
#include <linux/version.h>
#else
#define KERNEL_VERSION
#endif
#include "pvrsrv_error.h"
#include "img_types.h"
#include "cache_ops.h"
#include "device.h"
#include "pmr.h"
#include "pvrsrv_sync_km.h"
#include "connection_server.h"
PVRSRV_ERROR DmaDeviceParams(CONNECTION_DATA *psConnection,
PVRSRV_DEVICE_NODE *psDevNode,
IMG_UINT32 *ui32DmaBuffAlign,
IMG_UINT32 *ui32DmaTransferMult);
PVRSRV_ERROR DmaSparseMappingTable(PMR *psPMR,
IMG_DEVMEM_OFFSET_T uiOffset,
IMG_UINT32 ui32SizeInPages,
IMG_BOOL *pbTable);
PVRSRV_ERROR DmaTransfer(CONNECTION_DATA *psConnection,
PVRSRV_DEVICE_NODE *psDevNode,
IMG_UINT32 uiNumDMAs,
PMR** ppsPMR,
IMG_UINT64 *puiAddress,
IMG_DEVMEM_OFFSET_T *puiOffset,
IMG_DEVMEM_SIZE_T *puiSize,
IMG_UINT32 uiFlags,
PVRSRV_TIMELINE iUpdateTimeline);
PVRSRV_ERROR PVRSRVInitialiseDMA(PVRSRV_DEVICE_NODE *psDeviceNode,
CONNECTION_DATA *psConnectionData);
void PVRSRVDeInitialiseDMA(PVRSRV_DEVICE_NODE *psDeviceNode,
CONNECTION_DATA *psConnectionData);
#endif /* DMA_KM_H */

View File

@@ -0,0 +1,523 @@
/*************************************************************************/ /*!
@File dma_support.c
@Title System DMA support
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Provides a contiguous memory allocator (i.e. DMA allocator);
APIs are used for allocation/ioremapping (DMA/PA <-> CPU/VA)
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#include <linux/mm.h>
#include <asm/page.h>
#include <linux/device.h>
#include <linux/highmem.h>
#include <linux/vmalloc.h>
#include <linux/dma-mapping.h>
#include <asm-generic/getorder.h>
#include "allocmem.h"
#include "dma_support.h"
#include "pvr_vmap.h"
#include "kernel_compatibility.h"
#define DMA_MAX_IOREMAP_ENTRIES 2
static IMG_BOOL gbEnableDmaIoRemapping = IMG_FALSE;
static DMA_ALLOC gsDmaIoRemapArray[DMA_MAX_IOREMAP_ENTRIES] = {{0}};
static void*
SysDmaAcquireKernelAddress(struct page *psPage, IMG_UINT64 ui64Size, DMA_ALLOC *psDmaAlloc)
{
IMG_BOOL bPageByPage = IMG_TRUE;
IMG_UINT32 uiIdx;
void *pvVirtAddr = NULL;
IMG_UINT32 ui32PgCount = (IMG_UINT32)(ui64Size >> OSGetPageShift());
PVRSRV_DEVICE_NODE *psDevNode = OSAllocZMemNoStats(sizeof(*psDevNode));
PVRSRV_DEVICE_CONFIG *psDevConfig = OSAllocZMemNoStats(sizeof(*psDevConfig));
struct page **pagearray = OSAllocZMemNoStats(ui32PgCount * sizeof(struct page *));
void *pvOSDevice = psDmaAlloc->pvOSDevice;
#if defined(CONFIG_ARM64)
pgprot_t prot = pgprot_writecombine(PAGE_KERNEL);
#else
pgprot_t prot = pgprot_noncached(PAGE_KERNEL);
#endif
/* Validate all required dynamic tmp buffer allocations */
if (psDevNode == NULL || psDevConfig == NULL || pagearray == NULL)
{
if (psDevNode)
{
OSFreeMem(psDevNode);
}
if (psDevConfig)
{
OSFreeMem(psDevConfig);
}
if (pagearray)
{
OSFreeMem(pagearray);
}
goto e0;
}
/* Fake psDevNode->psDevConfig->pvOSDevice */
psDevConfig->pvOSDevice = pvOSDevice;
psDevNode->psDevConfig = psDevConfig;
/* Evict any page data contents from d-cache */
for (uiIdx = 0; uiIdx < ui32PgCount; uiIdx++)
{
void *pvVirtStart, *pvVirtEnd;
IMG_CPU_PHYADDR sCPUPhysStart, sCPUPhysEnd;
/* Prepare array required for vmap */
pagearray[uiIdx] = &psPage[uiIdx];
if (bPageByPage)
{
#if defined(CONFIG_64BIT)
bPageByPage = IMG_FALSE;
pvVirtStart = kmap(&psPage[uiIdx]);
pvVirtEnd = pvVirtStart + ui64Size;
sCPUPhysStart.uiAddr = page_to_phys(&psPage[uiIdx]);
sCPUPhysEnd.uiAddr = sCPUPhysStart.uiAddr + ui64Size;
/* all pages have a kernel linear address, flush entire range */
#else
pvVirtStart = kmap(&psPage[uiIdx]);
pvVirtEnd = pvVirtStart + PAGE_SIZE;
sCPUPhysStart.uiAddr = page_to_phys(&psPage[uiIdx]);
sCPUPhysEnd.uiAddr = sCPUPhysStart.uiAddr + PAGE_SIZE;
/* pages might be from HIGHMEM, need to kmap/flush per page */
#endif
/* Fallback to range-based d-cache flush */
OSCPUCacheInvalidateRangeKM(psDevNode,
pvVirtStart, pvVirtEnd,
sCPUPhysStart, sCPUPhysEnd);
kunmap(&psPage[uiIdx]);
}
}
/* Remap pages into VMALLOC space */
pvVirtAddr = pvr_vmap(pagearray, ui32PgCount, VM_MAP, prot);
psDmaAlloc->PageProps = prot;
/* Clean-up tmp buffers */
OSFreeMem(psDevConfig);
OSFreeMem(psDevNode);
OSFreeMem(pagearray);
e0:
return pvVirtAddr;
}
static void SysDmaReleaseKernelAddress(void *pvVirtAddr, IMG_UINT64 ui64Size, pgprot_t pgprot)
{
pvr_vunmap(pvVirtAddr, ui64Size >> OSGetPageShift(), pgprot);
}
/*!
******************************************************************************
@Function SysDmaAllocMem
@Description Allocates physically contiguous memory
@Return PVRSRV_ERROR PVRSRV_OK on success. Otherwise, a PVRSRV_
error code
******************************************************************************/
PVRSRV_ERROR SysDmaAllocMem(DMA_ALLOC *psDmaAlloc)
{
PVRSRV_ERROR eError = PVRSRV_OK;
struct device *psDev;
struct page *psPage;
size_t uiSize;
if (psDmaAlloc == NULL ||
psDmaAlloc->hHandle ||
psDmaAlloc->pvVirtAddr ||
psDmaAlloc->ui64Size == 0 ||
psDmaAlloc->sBusAddr.uiAddr ||
psDmaAlloc->pvOSDevice == NULL)
{
PVR_LOG_IF_FALSE((IMG_FALSE), "Invalid parameter");
return PVRSRV_ERROR_INVALID_PARAMS;
}
uiSize = PVR_ALIGN(psDmaAlloc->ui64Size, PAGE_SIZE);
psDev = (struct device *)psDmaAlloc->pvOSDevice;
psDmaAlloc->hHandle = dma_alloc_coherent(psDev, uiSize, (dma_addr_t *)&psDmaAlloc->sBusAddr.uiAddr, GFP_KERNEL);
if (psDmaAlloc->hHandle)
{
psDmaAlloc->pvVirtAddr = psDmaAlloc->hHandle;
PVR_DPF((PVR_DBG_MESSAGE,
"Allocated DMA buffer V:0x%p P:0x%llx S:0x"IMG_SIZE_FMTSPECX,
psDmaAlloc->pvVirtAddr,
psDmaAlloc->sBusAddr.uiAddr,
uiSize));
}
else if ((psPage = alloc_pages(GFP_KERNEL, get_order(uiSize))))
{
psDmaAlloc->sBusAddr.uiAddr = dma_map_page(psDev, psPage, 0, uiSize, DMA_BIDIRECTIONAL);
if (dma_mapping_error(psDev, psDmaAlloc->sBusAddr.uiAddr))
{
PVR_DPF((PVR_DBG_ERROR,
"dma_map_page() failed, page 0x%p order %d",
psPage,
get_order(uiSize)));
__free_pages(psPage, get_order(uiSize));
goto e0;
}
psDmaAlloc->psPage = psPage;
psDmaAlloc->pvVirtAddr = SysDmaAcquireKernelAddress(psPage, uiSize, psDmaAlloc);
if (! psDmaAlloc->pvVirtAddr)
{
PVR_DPF((PVR_DBG_ERROR,
"SysDmaAcquireKernelAddress() failed, page 0x%p order %d",
psPage,
get_order(uiSize)));
dma_unmap_page(psDev, psDmaAlloc->sBusAddr.uiAddr, uiSize, DMA_BIDIRECTIONAL);
__free_pages(psPage, get_order(uiSize));
goto e0;
}
PVR_DPF((PVR_DBG_MESSAGE,
"Allocated contiguous buffer V:0x%p P:0x%llx S:0x"IMG_SIZE_FMTSPECX,
psDmaAlloc->pvVirtAddr,
psDmaAlloc->sBusAddr.uiAddr,
uiSize));
}
else
{
PVR_DPF((PVR_DBG_ERROR, "Unable to allocate contiguous buffer, size: 0x"IMG_SIZE_FMTSPECX, uiSize));
eError = PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES;
}
e0:
PVR_LOG_RETURN_IF_FALSE((psDmaAlloc->pvVirtAddr), "DMA/CMA allocation failed", PVRSRV_ERROR_FAILED_TO_ALLOC_PAGES);
return eError;
}
/*!
******************************************************************************
@Function SysDmaFreeMem
@Description Free physically contiguous memory
@Return void
******************************************************************************/
void SysDmaFreeMem(DMA_ALLOC *psDmaAlloc)
{
size_t uiSize;
struct device *psDev;
if (psDmaAlloc == NULL ||
psDmaAlloc->ui64Size == 0 ||
psDmaAlloc->pvOSDevice == NULL ||
psDmaAlloc->pvVirtAddr == NULL ||
psDmaAlloc->sBusAddr.uiAddr == 0)
{
PVR_LOG_IF_FALSE((IMG_FALSE), "Invalid parameter");
return;
}
uiSize = PVR_ALIGN(psDmaAlloc->ui64Size, PAGE_SIZE);
psDev = (struct device *)psDmaAlloc->pvOSDevice;
if (psDmaAlloc->pvVirtAddr != psDmaAlloc->hHandle)
{
SysDmaReleaseKernelAddress(psDmaAlloc->pvVirtAddr, uiSize, psDmaAlloc->PageProps);
}
if (! psDmaAlloc->hHandle)
{
struct page *psPage;
dma_unmap_page(psDev, psDmaAlloc->sBusAddr.uiAddr, uiSize, DMA_BIDIRECTIONAL);
psPage = psDmaAlloc->psPage;
__free_pages(psPage, get_order(uiSize));
return;
}
dma_free_coherent(psDev, uiSize, psDmaAlloc->hHandle, (dma_addr_t )psDmaAlloc->sBusAddr.uiAddr);
}
/*!
******************************************************************************
@Function SysDmaRegisterForIoRemapping
@Description Registers DMA_ALLOC for manual I/O remapping
@Return PVRSRV_ERROR PVRSRV_OK on success. Otherwise, a PVRSRV_
error code
******************************************************************************/
PVRSRV_ERROR SysDmaRegisterForIoRemapping(DMA_ALLOC *psDmaAlloc)
{
size_t uiSize;
IMG_UINT32 ui32Idx;
IMG_BOOL bTabEntryFound = IMG_TRUE;
PVRSRV_ERROR eError = PVRSRV_ERROR_TOO_FEW_BUFFERS;
if (psDmaAlloc == NULL ||
psDmaAlloc->ui64Size == 0 ||
psDmaAlloc->pvOSDevice == NULL ||
psDmaAlloc->pvVirtAddr == NULL ||
psDmaAlloc->sBusAddr.uiAddr == 0)
{
PVR_LOG_IF_FALSE((IMG_FALSE), "Invalid parameter");
return PVRSRV_ERROR_INVALID_PARAMS;
}
uiSize = PVR_ALIGN(psDmaAlloc->ui64Size, PAGE_SIZE);
for (ui32Idx = 0; ui32Idx < DMA_MAX_IOREMAP_ENTRIES; ++ui32Idx)
{
/* Check if an I/O remap entry exists for remapping */
if (gsDmaIoRemapArray[ui32Idx].pvVirtAddr == NULL)
{
PVR_ASSERT(gsDmaIoRemapArray[ui32Idx].sBusAddr.uiAddr == 0);
PVR_ASSERT(gsDmaIoRemapArray[ui32Idx].ui64Size == 0);
break;
}
}
if (ui32Idx >= DMA_MAX_IOREMAP_ENTRIES)
{
bTabEntryFound = IMG_FALSE;
}
if (bTabEntryFound)
{
IMG_BOOL bSameVAddr, bSamePAddr, bSameSize;
bSamePAddr = gsDmaIoRemapArray[ui32Idx].sBusAddr.uiAddr == psDmaAlloc->sBusAddr.uiAddr;
bSameVAddr = gsDmaIoRemapArray[ui32Idx].pvVirtAddr == psDmaAlloc->pvVirtAddr;
bSameSize = gsDmaIoRemapArray[ui32Idx].ui64Size == uiSize;
if (bSameVAddr)
{
if (bSamePAddr && bSameSize)
{
eError = PVRSRV_OK;
}
else
{
eError = PVRSRV_ERROR_ALREADY_EXISTS;
}
}
else
{
PVR_ASSERT(bSamePAddr == IMG_FALSE);
gsDmaIoRemapArray[ui32Idx].ui64Size = uiSize;
gsDmaIoRemapArray[ui32Idx].sBusAddr = psDmaAlloc->sBusAddr;
gsDmaIoRemapArray[ui32Idx].pvVirtAddr = psDmaAlloc->pvVirtAddr;
PVR_DPF((PVR_DBG_MESSAGE,
"DMA: register I/O remap: "
"VA: 0x%p, PA: 0x%llx, Size: 0x"IMG_SIZE_FMTSPECX,
psDmaAlloc->pvVirtAddr,
psDmaAlloc->sBusAddr.uiAddr,
uiSize));
gbEnableDmaIoRemapping = IMG_TRUE;
eError = PVRSRV_OK;
}
}
return eError;
}
/*!
******************************************************************************
@Function SysDmaDeregisterForIoRemapping
@Description Deregisters DMA_ALLOC from manual I/O remapping
@Return void
******************************************************************************/
void SysDmaDeregisterForIoRemapping(DMA_ALLOC *psDmaAlloc)
{
__maybe_unused size_t uiSize;
IMG_UINT32 ui32Idx;
if (psDmaAlloc == NULL ||
psDmaAlloc->ui64Size == 0 ||
psDmaAlloc->pvOSDevice == NULL ||
psDmaAlloc->pvVirtAddr == NULL ||
psDmaAlloc->sBusAddr.uiAddr == 0)
{
PVR_LOG_IF_FALSE((IMG_FALSE), "Invalid parameter");
return;
}
uiSize = PVR_ALIGN(psDmaAlloc->ui64Size, PAGE_SIZE);
/* Remove specified entries from list of I/O remap entries */
for (ui32Idx = 0; ui32Idx < DMA_MAX_IOREMAP_ENTRIES; ++ui32Idx)
{
if (gsDmaIoRemapArray[ui32Idx].pvVirtAddr == psDmaAlloc->pvVirtAddr)
{
gsDmaIoRemapArray[ui32Idx].sBusAddr.uiAddr = 0;
gsDmaIoRemapArray[ui32Idx].pvVirtAddr = NULL;
gsDmaIoRemapArray[ui32Idx].ui64Size = 0;
PVR_DPF((PVR_DBG_MESSAGE,
"DMA: deregister I/O remap: "
"VA: 0x%p, PA: 0x%llx, Size: 0x"IMG_SIZE_FMTSPECX,
psDmaAlloc->pvVirtAddr,
psDmaAlloc->sBusAddr.uiAddr,
uiSize));
break;
}
}
/* Check if no other I/O remap entries exists for remapping */
for (ui32Idx = 0; ui32Idx < DMA_MAX_IOREMAP_ENTRIES; ++ui32Idx)
{
if (gsDmaIoRemapArray[ui32Idx].pvVirtAddr != NULL)
{
break;
}
}
if (ui32Idx == DMA_MAX_IOREMAP_ENTRIES)
{
/* No entries found so disable remapping */
gbEnableDmaIoRemapping = IMG_FALSE;
}
}
/*!
******************************************************************************
@Function SysDmaDevPAddrToCpuVAddr
@Description Maps a DMA_ALLOC physical address to CPU virtual address
@Return IMG_CPU_VIRTADDR on success. Otherwise, a NULL
******************************************************************************/
IMG_CPU_VIRTADDR SysDmaDevPAddrToCpuVAddr(IMG_UINT64 uiAddr, IMG_UINT64 ui64Size)
{
IMG_CPU_VIRTADDR pvDMAVirtAddr = NULL;
DMA_ALLOC *psHeapDmaAlloc;
IMG_UINT32 ui32Idx;
if (gbEnableDmaIoRemapping == IMG_FALSE)
{
return pvDMAVirtAddr;
}
for (ui32Idx = 0; ui32Idx < DMA_MAX_IOREMAP_ENTRIES; ++ui32Idx)
{
psHeapDmaAlloc = &gsDmaIoRemapArray[ui32Idx];
if (psHeapDmaAlloc->sBusAddr.uiAddr && uiAddr >= psHeapDmaAlloc->sBusAddr.uiAddr)
{
IMG_UINT64 uiSpan = psHeapDmaAlloc->ui64Size;
IMG_UINT64 uiOffset = uiAddr - psHeapDmaAlloc->sBusAddr.uiAddr;
if (uiOffset < uiSpan)
{
PVR_ASSERT((uiOffset+ui64Size-1) < uiSpan);
pvDMAVirtAddr = psHeapDmaAlloc->pvVirtAddr + uiOffset;
PVR_DPF((PVR_DBG_MESSAGE,
"DMA: remap: PA: 0x%llx => VA: 0x%p",
uiAddr, pvDMAVirtAddr));
break;
}
}
}
return pvDMAVirtAddr;
}
/*!
******************************************************************************
@Function SysDmaCpuVAddrToDevPAddr
@Description Maps a DMA_ALLOC CPU virtual address to physical address
@Return Non-zero value on success. Otherwise, a 0
******************************************************************************/
IMG_UINT64 SysDmaCpuVAddrToDevPAddr(IMG_CPU_VIRTADDR pvDMAVirtAddr)
{
IMG_UINT64 uiAddr = 0;
DMA_ALLOC *psHeapDmaAlloc;
IMG_UINT32 ui32Idx;
if (gbEnableDmaIoRemapping == IMG_FALSE)
{
return uiAddr;
}
for (ui32Idx = 0; ui32Idx < DMA_MAX_IOREMAP_ENTRIES; ++ui32Idx)
{
psHeapDmaAlloc = &gsDmaIoRemapArray[ui32Idx];
if (psHeapDmaAlloc->pvVirtAddr && pvDMAVirtAddr >= psHeapDmaAlloc->pvVirtAddr)
{
IMG_UINT64 uiSpan = psHeapDmaAlloc->ui64Size;
IMG_UINT64 uiOffset = pvDMAVirtAddr - psHeapDmaAlloc->pvVirtAddr;
if (uiOffset < uiSpan)
{
uiAddr = psHeapDmaAlloc->sBusAddr.uiAddr + uiOffset;
PVR_DPF((PVR_DBG_MESSAGE,
"DMA: remap: VA: 0x%p => PA: 0x%llx",
pvDMAVirtAddr, uiAddr));
break;
}
}
}
return uiAddr;
}
/******************************************************************************
End of file (dma_support.c)
******************************************************************************/

View File

@@ -0,0 +1,117 @@
/*************************************************************************/ /*!
@File dma_support.h
@Title Device contiguous memory allocator and I/O re-mapper
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description This header provides a contiguous memory allocator API; mainly
used for allocating / ioremapping (DMA/PA <-> CPU/VA)
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef DMA_SUPPORT_H
#define DMA_SUPPORT_H
#include "osfunc.h"
#include "pvrsrv.h"
typedef struct _DMA_ALLOC_
{
IMG_UINT64 ui64Size;
IMG_CPU_VIRTADDR pvVirtAddr;
IMG_DEV_PHYADDR sBusAddr;
IMG_HANDLE hHandle;
#if defined(__linux__)
struct page *psPage;
pgprot_t PageProps;
#endif
void *pvOSDevice;
} DMA_ALLOC;
/*!
*******************************************************************************
@Function SysDmaAllocMem
@Description Allocates physically contiguous memory
@Return PVRSRV_OK on success. Otherwise, a PVRSRV error code
******************************************************************************/
PVRSRV_ERROR SysDmaAllocMem(DMA_ALLOC *psDmaAlloc);
/*!
*******************************************************************************
@Function SysDmaFreeMem
@Description Free physically contiguous memory
@Return void
******************************************************************************/
void SysDmaFreeMem(DMA_ALLOC *psCmaAlloc);
/*!
*******************************************************************************
@Function SysDmaRegisterForIoRemapping
@Description Registers DMA_ALLOC for manual I/O remapping
@Return PVRSRV_OK on success. Otherwise, a PVRSRV error code
******************************************************************************/
PVRSRV_ERROR SysDmaRegisterForIoRemapping(DMA_ALLOC *psPhysHeapDmaAlloc);
/*!
*******************************************************************************
@Function SysDmaDeregisterForIoRemapping
@Description Deregisters DMA_ALLOC from manual I/O remapping
@Return void
******************************************************************************/
void SysDmaDeregisterForIoRemapping(DMA_ALLOC *psPhysHeapDmaAlloc);
/*!
*******************************************************************************
@Function SysDmaDevPAddrToCpuVAddr
@Description Maps a DMA_ALLOC physical address to CPU virtual address
@Return IMG_CPU_VIRTADDR on success. Otherwise, a NULL
******************************************************************************/
IMG_CPU_VIRTADDR
SysDmaDevPAddrToCpuVAddr(IMG_UINT64 uiAddr, IMG_UINT64 ui64Size);
/*!
*******************************************************************************
@Function SysDmaCpuVAddrToDevPAddr
@Description Maps a DMA_ALLOC CPU virtual address to physical address
@Return Non-zero value on success. Otherwise, a 0
******************************************************************************/
IMG_UINT64 SysDmaCpuVAddrToDevPAddr(IMG_CPU_VIRTADDR pvDMAVirtAddr);
#endif /* DMA_SUPPORT_H */
/******************************************************************************
End of file (dma_support.h)
******************************************************************************/

View File

@@ -0,0 +1,77 @@
/*************************************************************************/ /*!
@File
@Title Server side connection management
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Linux specific server side connection management
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#if !defined(ENV_CONNECTION_H)
#define ENV_CONNECTION_H
#include <linux/version.h>
#include <linux/list.h>
#include <linux/types.h>
#include "handle.h"
#include "pvr_debug.h"
#include "device.h"
struct drm_file;
typedef struct _ENV_CONNECTION_PRIVATE_DATA_
{
PVRSRV_DEVICE_NODE *psDevNode;
struct drm_file *psDRMFile;
} ENV_CONNECTION_PRIVATE_DATA;
typedef struct _ENV_CONNECTION_DATA_
{
pid_t owner;
PVRSRV_DEVICE_NODE *psDevNode;
struct drm_file *psDRMFile;
#if defined(SUPPORT_NATIVE_FENCE_SYNC)
void *pvPvrSyncPrivateData;
#endif
} ENV_CONNECTION_DATA;
#endif /* !defined(ENV_CONNECTION_H) */

View File

@@ -0,0 +1,523 @@
/*************************************************************************/ /*!
@File
@Title Event Object
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#include <asm/page.h>
#include <linux/io.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/pci.h>
#include <linux/version.h>
#include <linux/string.h>
#include <linux/sched.h>
#include <linux/sched/signal.h>
#include <linux/interrupt.h>
#include <asm/hardirq.h>
#include <linux/timer.h>
#include <linux/capability.h>
#include <linux/freezer.h>
#include <linux/uaccess.h>
#include "img_types.h"
#include "img_defs.h"
#include "pvrsrv_error.h"
#include "allocmem.h"
#include "event.h"
#include "pvr_debug.h"
#include "pvrsrv.h"
#include "pvr_bridge_k.h"
#include "osfunc.h"
/* Uncomment to enable event object stats that are useful for debugging.
* The stats can be gotten at any time (during lifetime of event object)
* using OSEventObjectDumpdebugInfo API */
// #define LINUX_EVENT_OBJECT_STATS
typedef struct PVRSRV_LINUX_EVENT_OBJECT_LIST_TAG
{
rwlock_t sLock;
/* Counts how many times event object was signalled i.e. how many times
* LinuxEventObjectSignal() was called on a given event object.
* Used for detecting pending signals.
* Note that this is in no way related to OS signals. */
atomic_t sEventSignalCount;
struct list_head sList;
} PVRSRV_LINUX_EVENT_OBJECT_LIST;
typedef struct PVRSRV_LINUX_EVENT_OBJECT_TAG
{
IMG_UINT32 ui32EventSignalCountPrevious;
#if defined(DEBUG)
IMG_UINT ui32Stats;
#endif
#ifdef LINUX_EVENT_OBJECT_STATS
POS_LOCK hLock;
IMG_UINT32 ui32ScheduleAvoided;
IMG_UINT32 ui32ScheduleCalled;
IMG_UINT32 ui32ScheduleSleptFully;
IMG_UINT32 ui32ScheduleSleptPartially;
IMG_UINT32 ui32ScheduleReturnedImmediately;
#endif
wait_queue_head_t sWait;
struct list_head sList;
PVRSRV_LINUX_EVENT_OBJECT_LIST *psLinuxEventObjectList;
} PVRSRV_LINUX_EVENT_OBJECT;
/*!
******************************************************************************
@Function LinuxEventObjectListCreate
@Description
Linux wait object list creation
@Output hOSEventKM : Pointer to the event object list handle
@Return PVRSRV_ERROR : Error code
******************************************************************************/
PVRSRV_ERROR LinuxEventObjectListCreate(IMG_HANDLE *phEventObjectList)
{
PVRSRV_LINUX_EVENT_OBJECT_LIST *psEvenObjectList;
psEvenObjectList = OSAllocMem(sizeof(*psEvenObjectList));
if (psEvenObjectList == NULL)
{
PVR_DPF((PVR_DBG_ERROR, "LinuxEventObjectCreate: failed to allocate memory for event list"));
return PVRSRV_ERROR_OUT_OF_MEMORY;
}
INIT_LIST_HEAD(&psEvenObjectList->sList);
rwlock_init(&psEvenObjectList->sLock);
atomic_set(&psEvenObjectList->sEventSignalCount, 0);
*phEventObjectList = (IMG_HANDLE *) psEvenObjectList;
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function LinuxEventObjectListDestroy
@Description
Linux wait object list destruction
@Input hOSEventKM : Event object list handle
@Return PVRSRV_ERROR : Error code
******************************************************************************/
PVRSRV_ERROR LinuxEventObjectListDestroy(IMG_HANDLE hEventObjectList)
{
PVRSRV_LINUX_EVENT_OBJECT_LIST *psEvenObjectList = (PVRSRV_LINUX_EVENT_OBJECT_LIST *) hEventObjectList;
if (psEvenObjectList)
{
if (!list_empty(&psEvenObjectList->sList))
{
struct list_head *list;
PVR_DPF((PVR_DBG_ERROR, "%s: Event List is not empty", __func__));
list_for_each(list, &psEvenObjectList->sList)
{
PVRSRV_LINUX_EVENT_OBJECT *psEvent;
psEvent = list_entry(list, PVRSRV_LINUX_EVENT_OBJECT, sList);
PVR_DPF((PVR_DBG_ERROR, "%s: Event Object @ " IMG_KM_PTR_FMTSPEC , __func__, psEvent));
}
return PVRSRV_ERROR_UNABLE_TO_DESTROY_EVENT;
}
OSFreeMem(psEvenObjectList);
/*not nulling pointer, copy on stack*/
}
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function LinuxEventObjectDelete
@Description
Linux wait object removal
@Input hOSEventObject : Event object handle
@Return PVRSRV_ERROR : Error code
******************************************************************************/
PVRSRV_ERROR LinuxEventObjectDelete(IMG_HANDLE hOSEventObject)
{
if (hOSEventObject)
{
PVRSRV_LINUX_EVENT_OBJECT *psLinuxEventObject = (PVRSRV_LINUX_EVENT_OBJECT *)hOSEventObject;
PVRSRV_LINUX_EVENT_OBJECT_LIST *psLinuxEventObjectList = psLinuxEventObject->psLinuxEventObjectList;
write_lock_bh(&psLinuxEventObjectList->sLock);
list_del(&psLinuxEventObject->sList);
write_unlock_bh(&psLinuxEventObjectList->sLock);
#ifdef LINUX_EVENT_OBJECT_STATS
OSLockDestroy(psLinuxEventObject->hLock);
#endif
#if defined(DEBUG)
// PVR_DPF((PVR_DBG_MESSAGE, "LinuxEventObjectDelete: Event object waits: %u", psLinuxEventObject->ui32Stats));
#endif
OSFreeMem(psLinuxEventObject);
/*not nulling pointer, copy on stack*/
return PVRSRV_OK;
}
return PVRSRV_ERROR_UNABLE_TO_DESTROY_EVENT;
}
/*!
******************************************************************************
@Function LinuxEventObjectAdd
@Description
Linux wait object addition
@Input hOSEventObjectList : Event object list handle
@Output phOSEventObject : Pointer to the event object handle
@Return PVRSRV_ERROR : Error code
******************************************************************************/
PVRSRV_ERROR LinuxEventObjectAdd(IMG_HANDLE hOSEventObjectList, IMG_HANDLE *phOSEventObject)
{
PVRSRV_LINUX_EVENT_OBJECT *psLinuxEventObject;
PVRSRV_LINUX_EVENT_OBJECT_LIST *psLinuxEventObjectList = (PVRSRV_LINUX_EVENT_OBJECT_LIST*)hOSEventObjectList;
/* allocate completion variable */
psLinuxEventObject = OSAllocMem(sizeof(*psLinuxEventObject));
if (psLinuxEventObject == NULL)
{
PVR_DPF((PVR_DBG_ERROR, "LinuxEventObjectAdd: failed to allocate memory"));
return PVRSRV_ERROR_OUT_OF_MEMORY;
}
INIT_LIST_HEAD(&psLinuxEventObject->sList);
/* Start with the timestamp at which event object was added to the list */
psLinuxEventObject->ui32EventSignalCountPrevious = atomic_read(&psLinuxEventObjectList->sEventSignalCount);
#ifdef LINUX_EVENT_OBJECT_STATS
PVR_LOG_RETURN_IF_ERROR(OSLockCreate(&psLinuxEventObject->hLock), "OSLockCreate");
psLinuxEventObject->ui32ScheduleAvoided = 0;
psLinuxEventObject->ui32ScheduleCalled = 0;
psLinuxEventObject->ui32ScheduleSleptFully = 0;
psLinuxEventObject->ui32ScheduleSleptPartially = 0;
psLinuxEventObject->ui32ScheduleReturnedImmediately = 0;
#endif
#if defined(DEBUG)
psLinuxEventObject->ui32Stats = 0;
#endif
init_waitqueue_head(&psLinuxEventObject->sWait);
psLinuxEventObject->psLinuxEventObjectList = psLinuxEventObjectList;
write_lock_bh(&psLinuxEventObjectList->sLock);
list_add(&psLinuxEventObject->sList, &psLinuxEventObjectList->sList);
write_unlock_bh(&psLinuxEventObjectList->sLock);
*phOSEventObject = psLinuxEventObject;
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function LinuxEventObjectSignal
@Description
Linux wait object signaling function
@Input hOSEventObjectList : Event object list handle
@Return PVRSRV_ERROR : Error code
******************************************************************************/
PVRSRV_ERROR LinuxEventObjectSignal(IMG_HANDLE hOSEventObjectList)
{
PVRSRV_LINUX_EVENT_OBJECT *psLinuxEventObject;
PVRSRV_LINUX_EVENT_OBJECT_LIST *psLinuxEventObjectList = (PVRSRV_LINUX_EVENT_OBJECT_LIST*)hOSEventObjectList;
struct list_head *psListEntry, *psListEntryTemp, *psList;
psList = &psLinuxEventObjectList->sList;
/* Move the timestamp ahead for this call, so a potential "Wait" from any
* EventObject/s doesn't wait for the signal to occur before returning. Early
* setting/incrementing of timestamp reduces the window where a concurrent
* "Wait" call might block while "this" Signal call is being processed */
atomic_inc(&psLinuxEventObjectList->sEventSignalCount);
read_lock_bh(&psLinuxEventObjectList->sLock);
list_for_each_safe(psListEntry, psListEntryTemp, psList)
{
psLinuxEventObject = (PVRSRV_LINUX_EVENT_OBJECT *)list_entry(psListEntry, PVRSRV_LINUX_EVENT_OBJECT, sList);
wake_up_interruptible(&psLinuxEventObject->sWait);
}
read_unlock_bh(&psLinuxEventObjectList->sLock);
return PVRSRV_OK;
}
static void _TryToFreeze(void)
{
/* if we reach zero it means that all of the threads called try_to_freeze */
LinuxBridgeNumActiveKernelThreadsDecrement();
/* Returns true if the thread was frozen, should we do anything with this
* information? What do we return? Which one is the error case? */
try_to_freeze();
LinuxBridgeNumActiveKernelThreadsIncrement();
}
void LinuxEventObjectDumpDebugInfo(IMG_HANDLE hOSEventObject)
{
#ifdef LINUX_EVENT_OBJECT_STATS
PVRSRV_LINUX_EVENT_OBJECT *psLinuxEventObject = (PVRSRV_LINUX_EVENT_OBJECT *)hOSEventObject;
OSLockAcquire(psLinuxEventObject->hLock);
PVR_LOG(("%s: EvObj("IMG_KM_PTR_FMTSPEC ") schedule: Avoided(%u) Called(%u) ReturnedImmediately(%u) SleptFully(%u) SleptPartially(%u)",
__func__, psLinuxEventObject, psLinuxEventObject->ui32ScheduleAvoided,
psLinuxEventObject->ui32ScheduleCalled, psLinuxEventObject->ui32ScheduleReturnedImmediately,
psLinuxEventObject->ui32ScheduleSleptFully, psLinuxEventObject->ui32ScheduleSleptPartially));
OSLockRelease(psLinuxEventObject->hLock);
#else
PVR_LOG(("%s: LINUX_EVENT_OBJECT_STATS disabled!", __func__));
#endif
}
/*!
******************************************************************************
@Function LinuxEventObjectWait
@Description
Linux wait object routine
@Input hOSEventObject : Event object handle
@Input ui64Timeoutus : Time out value in usec
@Return PVRSRV_ERROR : Error code
******************************************************************************/
PVRSRV_ERROR LinuxEventObjectWait(IMG_HANDLE hOSEventObject,
IMG_UINT64 ui64Timeoutus,
IMG_BOOL bFreezable)
{
IMG_UINT32 ui32EventSignalCount;
PVRSRV_DATA *psPVRSRVData = PVRSRVGetPVRSRVData();
IMG_UINT32 ui32Remainder;
long timeOutJiffies;
#ifdef LINUX_EVENT_OBJECT_STATS
long totalTimeoutJiffies;
IMG_BOOL bScheduleCalled = IMG_FALSE;
#endif
DEFINE_WAIT(sWait);
PVRSRV_LINUX_EVENT_OBJECT *psLinuxEventObject = (PVRSRV_LINUX_EVENT_OBJECT*)hOSEventObject;
PVRSRV_LINUX_EVENT_OBJECT_LIST *psLinuxEventObjectList = psLinuxEventObject->psLinuxEventObjectList;
PVR_ASSERT(psLinuxEventObjectList != NULL);
/* Check if the driver is good shape */
if (psPVRSRVData->eServicesState != PVRSRV_SERVICES_STATE_OK)
{
return PVRSRV_ERROR_TIMEOUT;
}
/* usecs_to_jiffies only takes an uint. So if our timeout is bigger than an
* uint use the msec version. With such a long timeout we really don't need
* the high resolution of usecs. */
if (ui64Timeoutus > 0xffffffffULL)
timeOutJiffies = msecs_to_jiffies(OSDivide64(ui64Timeoutus, 1000, &ui32Remainder));
else
timeOutJiffies = usecs_to_jiffies(ui64Timeoutus);
#ifdef LINUX_EVENT_OBJECT_STATS
totalTimeoutJiffies = timeOutJiffies;
#endif
do
{
prepare_to_wait(&psLinuxEventObject->sWait, &sWait, TASK_INTERRUPTIBLE);
ui32EventSignalCount = (IMG_UINT32) atomic_read(&psLinuxEventObjectList->sEventSignalCount);
if (psLinuxEventObject->ui32EventSignalCountPrevious != ui32EventSignalCount)
{
/* There is a pending event signal i.e. LinuxEventObjectSignal()
* was called on the event object since the last time we checked.
* Return without waiting. */
break;
}
if (signal_pending(current))
{
/* There is an OS signal pending so return.
* This allows to kill/interrupt user space processes which
* are waiting on this event object. */
break;
}
#ifdef LINUX_EVENT_OBJECT_STATS
bScheduleCalled = IMG_TRUE;
#endif
timeOutJiffies = schedule_timeout(timeOutJiffies);
if (bFreezable)
{
_TryToFreeze();
}
#if defined(DEBUG)
psLinuxEventObject->ui32Stats++;
#endif
} while (timeOutJiffies);
finish_wait(&psLinuxEventObject->sWait, &sWait);
psLinuxEventObject->ui32EventSignalCountPrevious = ui32EventSignalCount;
#ifdef LINUX_EVENT_OBJECT_STATS
OSLockAcquire(psLinuxEventObject->hLock);
if (bScheduleCalled)
{
psLinuxEventObject->ui32ScheduleCalled++;
if (totalTimeoutJiffies == timeOutJiffies)
{
psLinuxEventObject->ui32ScheduleReturnedImmediately++;
}
else if (timeOutJiffies == 0)
{
psLinuxEventObject->ui32ScheduleSleptFully++;
}
else
{
psLinuxEventObject->ui32ScheduleSleptPartially++;
}
}
else
{
psLinuxEventObject->ui32ScheduleAvoided++;
}
OSLockRelease(psLinuxEventObject->hLock);
#endif
if (signal_pending(current) && test_tsk_thread_flag(current, TIF_SIGPENDING))
{
return PVRSRV_ERROR_INTERRUPTED;
}
else
{
return timeOutJiffies ? PVRSRV_OK : PVRSRV_ERROR_TIMEOUT;
}
}
#if defined(PVRSRV_SERVER_THREADS_INDEFINITE_SLEEP)
PVRSRV_ERROR LinuxEventObjectWaitUntilSignalled(IMG_HANDLE hOSEventObject)
{
PVRSRV_DATA *psPVRSRVData = PVRSRVGetPVRSRVData();
DEFINE_WAIT(sWait);
PVRSRV_LINUX_EVENT_OBJECT *psLinuxEventObject =
(PVRSRV_LINUX_EVENT_OBJECT *) hOSEventObject;
PVRSRV_LINUX_EVENT_OBJECT_LIST *psLinuxEventObjectList =
psLinuxEventObject->psLinuxEventObjectList;
/* Check if the driver is in good shape */
if (psPVRSRVData->eServicesState != PVRSRV_SERVICES_STATE_OK)
{
return PVRSRV_ERROR_TIMEOUT;
}
prepare_to_wait(&psLinuxEventObject->sWait, &sWait, TASK_INTERRUPTIBLE);
if (psLinuxEventObject->ui32EventSignalCountPrevious !=
(IMG_UINT32) atomic_read(&psLinuxEventObjectList->sEventSignalCount))
{
/* There is a pending signal, so return without waiting */
goto finish;
}
schedule();
_TryToFreeze();
finish:
finish_wait(&psLinuxEventObject->sWait, &sWait);
psLinuxEventObject->ui32EventSignalCountPrevious =
(IMG_UINT32) atomic_read(&psLinuxEventObjectList->sEventSignalCount);
return PVRSRV_OK;
}
#endif /* defined(PVRSRV_SERVER_THREADS_INDEFINITE_SLEEP) */

View File

@@ -0,0 +1,54 @@
/*************************************************************************/ /*!
@File
@Title Event Object
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
PVRSRV_ERROR LinuxEventObjectListCreate(IMG_HANDLE *phEventObjectList);
PVRSRV_ERROR LinuxEventObjectListDestroy(IMG_HANDLE hEventObjectList);
PVRSRV_ERROR LinuxEventObjectAdd(IMG_HANDLE hOSEventObjectList, IMG_HANDLE *phOSEventObject);
PVRSRV_ERROR LinuxEventObjectDelete(IMG_HANDLE hOSEventObject);
PVRSRV_ERROR LinuxEventObjectSignal(IMG_HANDLE hOSEventObjectList);
PVRSRV_ERROR LinuxEventObjectWait(IMG_HANDLE hOSEventObject,
IMG_UINT64 ui64Timeoutus,
IMG_BOOL bFreezable);
#if defined(PVRSRV_SERVER_THREADS_INDEFINITE_SLEEP)
PVRSRV_ERROR LinuxEventObjectWaitUntilSignalled(IMG_HANDLE hOSEventObject);
#endif
void LinuxEventObjectDumpDebugInfo(IMG_HANDLE hOSEventObject);

View File

@@ -0,0 +1,261 @@
/*************************************************************************/ /*!
@File
@Title Services firmware load and access routines for Linux
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Device specific functions
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#include <linux/firmware.h>
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/err.h>
#include "device.h"
#include "module_common.h"
#include "fwload.h"
#include "pvr_debug.h"
#include "srvkm.h"
#if defined(RGX_FW_SIGNED)
#include <linux/verification.h>
#include <linux/module.h>
#include <crypto/public_key.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
#include <linux/module_signature.h>
#else
#define PKEY_ID_PKCS7 2
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) */
#include "signfw.h"
#endif /* RGX_FW_SIGNED */
struct OS_FW_IMAGE_t
{
const struct firmware *psFW;
size_t uSignatureSize;
};
#if defined(RGX_FW_SIGNED)
static int OSCheckSignature(const struct FirmwareSignatureHeader *psHeader, size_t uSize)
{
if (be32_to_cpu(psHeader->ui32SignatureLen) >= uSize - sizeof(*psHeader))
{
return -EBADMSG;
}
if (psHeader->ui8IDType != PKEY_ID_PKCS7)
{
return -ENOPKG;
}
if (psHeader->ui8Algo != 0 || psHeader->ui8HashAlgo != 0 ||
psHeader->ui8SignerLen != 0 || psHeader->ui8KeyIDLen != 0 ||
psHeader->__ui8Padding[0] != 0 || psHeader->__ui8Padding[1] != 0 ||
psHeader->__ui8Padding[2] != 0)
{
return -EBADMSG;
}
return 0;
}
bool OSVerifyFirmware(OS_FW_IMAGE *psFWImage)
{
const struct firmware *psFW = psFWImage->psFW;
const u8 *pui8FWData = psFW->data;
size_t uFWSize = psFW->size;
uint32_t ui32MagicLen = sizeof(MODULE_SIG_STRING) - 1;
struct FirmwareSignatureHeader sHeader;
int err;
if (uFWSize <= ui32MagicLen)
{
return false;
}
/*
* Linux Kernel's sign-file utility is primarily intended for signing
* modules, and so appends the MODULE_SIG_STRING magic at the end of
* the signature. Only proceed with verification if this magic is found.
*/
if (memcmp(pui8FWData + uFWSize - ui32MagicLen, MODULE_SIG_STRING, ui32MagicLen) != 0)
{
return false;
}
uFWSize -= ui32MagicLen;
if (uFWSize <= sizeof(sHeader))
{
return false;
}
/*
* After the magic, a header is placed which informs about the digest /
* crypto algorithm etc. Copy that header and ensure that it has valid
* contents (We only support RSA Crypto, SHA Hash, X509 certificate and
* PKCS#7 signature).
*/
memcpy(&sHeader, pui8FWData + (uFWSize - sizeof(sHeader)), sizeof(sHeader));
if (OSCheckSignature(&sHeader, uFWSize) != 0)
{
return false;
}
/*
* As all information is now extracted, we can go ahead and ask PKCS
* module to verify the sign.
*/
uFWSize -= be32_to_cpu(sHeader.ui32SignatureLen) + sizeof(sHeader);
err = verify_pkcs7_signature(pui8FWData, uFWSize, pui8FWData + uFWSize,
be32_to_cpu(sHeader.ui32SignatureLen), NULL,
VERIFYING_UNSPECIFIED_SIGNATURE, NULL, NULL);
if (err == 0)
{
psFWImage->uSignatureSize = psFW->size - uFWSize;
PVR_DPF((PVR_DBG_MESSAGE, "%s: Firmware Successfully Verified",
__func__));
return true;
}
PVR_DPF((PVR_DBG_WARNING, "%s: Firmware Verification Failed (%d)",
__func__, err));
return false;
}
#else /* defined(RGX_FW_SIGNED) */
inline bool OSVerifyFirmware(OS_FW_IMAGE *psFWImage)
{
return true;
}
#endif /* defined(RGX_FW_SIGNED) */
PVRSRV_ERROR
OSLoadFirmware(PVRSRV_DEVICE_NODE *psDeviceNode, const IMG_CHAR *pszBVNCString,
bool (*pfnVerifyFirmware)(OS_FW_IMAGE*), OS_FW_IMAGE **ppsFWImage)
{
const struct firmware *psFW = NULL;
OS_FW_IMAGE *psFWImage;
IMG_INT32 res;
PVRSRV_ERROR eError;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
res = firmware_request_nowarn(&psFW, pszBVNCString, psDeviceNode->psDevConfig->pvOSDevice);
#else
res = request_firmware(&psFW, pszBVNCString, psDeviceNode->psDevConfig->pvOSDevice);
#endif
if (res != 0)
{
release_firmware(psFW);
if (res == -ENOENT)
{
PVR_DPF((PVR_DBG_WARNING, "%s: requested firmware('%s') not found (%d)",
__func__, pszBVNCString, res));
eError = PVRSRV_ERROR_NOT_FOUND;
}
else
{
PVR_DPF((PVR_DBG_WARNING, "%s: requested firmware('%s') not ready (%d)",
__func__, pszBVNCString, res));
eError = PVRSRV_ERROR_NOT_READY;
}
goto err_exit;
}
psFWImage = OSAllocZMem(sizeof(*psFWImage));
if (psFWImage == NULL)
{
PVR_DPF((PVR_DBG_WARNING, "%s: OSAllocZMem('%s') failed.",
__func__, pszBVNCString));
release_firmware(psFW);
eError = PVRSRV_ERROR_OUT_OF_MEMORY;
goto err_exit;
}
psFWImage->psFW = psFW;
#if !defined(SUPPORT_CUSTOMER_SIGNING)
if (pfnVerifyFirmware != NULL && !pfnVerifyFirmware(psFWImage))
{
release_firmware(psFW);
OSFreeMem(psFWImage);
eError = PVRSRV_ERROR_NOT_AUTHENTICATED;
goto err_exit;
}
#endif
*ppsFWImage = psFWImage;
return PVRSRV_OK;
err_exit:
*ppsFWImage = NULL;
return eError;
}
void
OSUnloadFirmware(OS_FW_IMAGE *psFWImage)
{
const struct firmware *psFW = psFWImage->psFW;
release_firmware(psFW);
OSFreeMem(psFWImage);
}
size_t
OSFirmwareSize(OS_FW_IMAGE *psFWImage)
{
const struct firmware *psFW = psFWImage->psFW;
return psFW->size - psFWImage->uSignatureSize;
}
const void *
OSFirmwareData(OS_FW_IMAGE *psFWImage)
{
const struct firmware *psFW = psFWImage->psFW;
return psFW->data;
}
/******************************************************************************
End of file (fwload.c)
******************************************************************************/

View File

@@ -0,0 +1,158 @@
/*************************************************************************/ /*!
@File
@Title Services RGX OS Interface for loading the firmware
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description This file defines the OS interface through which the RGX
device initialisation code in the kernel/server will obtain
the RGX firmware binary image. The API is used during the
initialisation of an RGX device via the
PVRSRVCommonDeviceInitialise()
call sequence.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef FWLOAD_H
#define FWLOAD_H
#include "img_defs.h"
#include "device_connection.h"
#include "device.h"
/*! Opaque type handle defined and known to the OS layer implementation of this
* fwload.h OS API. This private data is allocated in the implementation of
* OSLoadFirmware() and contains whatever data and information needed to be
* able to acquire and return the firmware binary image to the Services
* kernel/server during initialisation.
* It is no longer required and may be freed when OSUnloadFirmware() is called.
*/
typedef struct OS_FW_IMAGE_t OS_FW_IMAGE;
#if defined(__linux__)
bool OSVerifyFirmware(OS_FW_IMAGE* psFWImage);
#endif
/*************************************************************************/ /*!
@Function OSLoadFirmware
@Description The OS implementation must load or acquire the firmware (FW)
image binary needed by the driver stack.
A handle to the common layer device node is given to identify
which device instance in the system is being initialised. The
BVNC string is also supplied so that the implementation knows
which FW image to retrieve since each FW image only supports one
GPU type/revision.
The calling server code supports multiple GPU types and revisions
and will detect the specific GPU type and revision before calling
this API. It will also have runtime configuration of the VZ mode,
hence this API must be able to retrieve different FW binary
images based on the pszBVNCString given. The purpose of the end
platform/system is key to understand which FW images must be
available to the kernel server.
On exit the implementation must return a pointer to some private
data it uses to hold the FW image information and data. It will
be passed onto later API calls by the kernel server code.
NULL should be returned if the FW image could not be retrieved.
The format of the BVNC string is as follows ([x] denotes
optional field):
"rgx.fw[.signed].B.V[p].N.C[.vz]"
The implementation must first try to load the FW identified
by the pszBVpNCString parameter. If this is not available then it
should drop back to retrieving the FW identified by the
pszBVNCString parameter. The fields in the string are:
B, V, N, C are all unsigned integer identifying type/revision.
[.signed] is present when RGX_FW_SIGNED=1 is defined in the
server build.
[p] denotes a provisional (pre-silicon) GPU configuration.
[.vz] is present when the kernel server is loaded on the HOST
of a virtualised platform. See the DriverMode server
AppHint for details.
@Input psDeviceNode Device instance identifier.
@Input pszBVNCString Identifier string of the FW image to
be loaded/acquired in production driver.
@Input pfnVerifyFirmware Callback which checks validity of FW image.
@Output ppsFWImage Ptr to private data on success,
NULL otherwise.
@Return PVRSRV_ERROR PVRSRV_OK on success,
PVRSRV_ERROR_NOT_READY if filesystem is not
ready/initialised,
PVRSRV_ERROR_NOT_FOUND if no suitable FW
image could be found
PVRSRV_ERROR_OUT_OF_MEMORY if unable to alloc
memory for FW image
PVRSRV_ERROR_NOT_AUTHENTICATED if FW image
cannot be verified.
*/ /**************************************************************************/
PVRSRV_ERROR OSLoadFirmware(PVRSRV_DEVICE_NODE *psDeviceNode,
const IMG_CHAR *pszBVNCString,
bool (*pfnVerifyFirmware)(OS_FW_IMAGE*),
OS_FW_IMAGE **ppsFWImage);
/*************************************************************************/ /*!
@Function OSFirmwareData
@Description This function returns a pointer to the start of the FW image
binary data held in memory. It must remain valid until
OSUnloadFirmware() is called.
@Input psFWImage Private data opaque handle
@Return void* Ptr to FW binary image to start on GPU.
*/ /**************************************************************************/
const void* OSFirmwareData(OS_FW_IMAGE *psFWImage);
/*************************************************************************/ /*!
@Function OSFirmwareSize
@Description This function returns the size of the FW image binary data.
@Input psFWImage Private data opaque handle
@Return size_t Size in bytes of the firmware binary image
*/ /**************************************************************************/
size_t OSFirmwareSize(OS_FW_IMAGE *psFWImage);
/*************************************************************************/ /*!
@Function OSUnloadFirmware
@Description This is called when the server has completed firmware
initialisation and no longer needs the private data, possibly
allocated by OSLoadFirmware().
@Input psFWImage Private data opaque handle
*/ /**************************************************************************/
void OSUnloadFirmware(OS_FW_IMAGE *psFWImage);
#endif /* FWLOAD_H */
/******************************************************************************
End of file (fwload.h)
******************************************************************************/

View File

@@ -0,0 +1,52 @@
/*************************************************************************/ /*!
@File fwtrace_string.h
@Title RGX Firmware trace strings for KM
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Platform Generic
@Description This file defines SFs tuple.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef KM_TRACE_STRING_H
#define KM_TRACE_STRING_H
#include "rgx_fwif_sf.h"
extern const RGXKM_STID_FMT SFs[];
extern const IMG_UINT32 g_ui32SFsCount;
#endif /* KM_TRACE_STRING_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,206 @@
/**************************************************************************/ /*!
@File
@Title Handle Manager API
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Provide handle management
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /***************************************************************************/
#if !defined(HANDLE_API_H)
#define HANDLE_API_H
#include "lock_types.h"
/*
* Handle API
* ----------
* The handle API is intended to provide handles for kernel resources, which
* can then be passed back to user space processes.
*
* The following functions comprise the API. Each function takes a pointer to
* a PVRSRV_HANDLE_BASE structure, one of which is allocated for each process,
* and stored in the per-process data area. Use KERNEL_HANDLE_BASE for handles
* not allocated for a particular process, or for handles that need to be
* allocated before the PVRSRV_HANDLE_BASE structure for the process is
* available.
*
* PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase,
* IMG_HANDLE *phHandle, void *pvData, PVRSRV_HANDLE_TYPE eType,
* PVRSRV_HANDLE_ALLOC_FLAG eFlag);
*
* Allocate a handle phHandle, for the resource of type eType pointed to by
* pvData.
*
* For handles that have a definite lifetime, where the corresponding resource
* is explicitly created and destroyed, eFlag should be zero.
*
* If a particular resource may be referenced multiple times by a given
* process, setting eFlag to PVRSRV_HANDLE_ALLOC_FLAG_MULTI will allow multiple
* handles to be allocated for the resource. Such handles cannot be found with
* PVRSRVFindHandle.
*
* PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase,
* IMG_HANDLE *phHandle, void *pvData, PVRSRV_HANDLE_TYPE eType,
* PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_HANDLE hParent);
*
* This function is similar to PVRSRVAllocHandle, except that the allocated
* handles are associated with a parent handle, hParent, that has been
* allocated previously. Subhandles are automatically deallocated when their
* parent handle is deallocated.
* Subhandles can be treated as ordinary handles. For example, they may have
* subhandles of their own, and may be explicitly deallocated using
* PVRSRVReleaseHandle (see below).
*
* PVRSRV_ERROR PVRSRVFindHandle(PVRSRV_HANDLE_BASE *psBase,
* IMG_HANDLE *phHandle, void *pvData, PVRSRV_HANDLE_TYPE eType);
*
* Find the handle previously allocated for the resource pointed to by pvData,
* of type eType. Handles allocated with the flag
* PVRSRV_HANDLE_ALLOC_FLAG_MULTI cannot be found using this function.
*
* PVRSRV_ERROR PVRSRVLookupHandle(PVRSRV_HANDLE_BASE *psBase,
* void **ppvData, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType);
*
* Given a handle for a resource of type eType, return the pointer to the
* resource.
*
* PVRSRV_ERROR PVRSRVLookupSubHandle(PVRSRV_HANDLE_BASE *psBase,
* void **ppvData, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType,
* IMH_HANDLE hAncestor);
*
* Similar to PVRSRVLookupHandle, but checks the handle is a descendant
* of hAncestor.
*
* PVRSRV_ERROR PVRSRVReleaseHandle(PVRSRV_HANDLE_BASE *psBase,
* IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType);
*
* Deallocate a handle of given type.
*
* Return the parent of a handle in *phParent, or NULL if the handle has
* no parent.
*/
#include "img_types.h"
#include "img_defs.h"
#include "hash.h"
typedef enum
{
#define HANDLETYPE(x) PVRSRV_HANDLE_TYPE_##x,
#include "handle_types.h"
#undef HANDLETYPE
} PVRSRV_HANDLE_TYPE;
static_assert(PVRSRV_HANDLE_TYPE_NONE == 0, "PVRSRV_HANDLE_TYPE_NONE must be zero");
typedef enum
{
PVRSRV_HANDLE_BASE_TYPE_CONNECTION,
PVRSRV_HANDLE_BASE_TYPE_PROCESS,
PVRSRV_HANDLE_BASE_TYPE_GLOBAL
} PVRSRV_HANDLE_BASE_TYPE;
typedef enum
{
/* No flags */
PVRSRV_HANDLE_ALLOC_FLAG_NONE = 0,
/* Multiple handles can point at the given data pointer */
PVRSRV_HANDLE_ALLOC_FLAG_MULTI = 0x01,
/* Subhandles are allocated in a private handle space */
PVRSRV_HANDLE_ALLOC_FLAG_PRIVATE = 0x02
} PVRSRV_HANDLE_ALLOC_FLAG;
typedef struct _HANDLE_BASE_ PVRSRV_HANDLE_BASE;
typedef struct _PROCESS_HANDLE_BASE_
{
PVRSRV_HANDLE_BASE *psHandleBase;
ATOMIC_T iRefCount;
uintptr_t uiHashKey;
} PROCESS_HANDLE_BASE;
extern PVRSRV_HANDLE_BASE *gpsKernelHandleBase;
#define KERNEL_HANDLE_BASE (gpsKernelHandleBase)
#define HANDLE_DEBUG_LISTING_MAX_NUM 20
typedef PVRSRV_ERROR (*PFN_HANDLE_RELEASE)(void *pvData);
PVRSRV_ERROR PVRSRVAllocHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, void *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, PFN_HANDLE_RELEASE pfnReleaseData);
PVRSRV_ERROR PVRSRVAllocHandleUnlocked(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, void *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, PFN_HANDLE_RELEASE pfnReleaseData);
PVRSRV_ERROR PVRSRVAllocSubHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, void *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_HANDLE hParent);
PVRSRV_ERROR PVRSRVAllocSubHandleUnlocked(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, void *pvData, PVRSRV_HANDLE_TYPE eType, PVRSRV_HANDLE_ALLOC_FLAG eFlag, IMG_HANDLE hParent);
PVRSRV_ERROR PVRSRVFindHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, void *pvData, PVRSRV_HANDLE_TYPE eType);
PVRSRV_ERROR PVRSRVFindHandleUnlocked(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE *phHandle, void *pvData, PVRSRV_HANDLE_TYPE eType);
PVRSRV_ERROR PVRSRVLookupHandle(PVRSRV_HANDLE_BASE *psBase, void **ppvData, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType, IMG_BOOL bRef);
PVRSRV_ERROR PVRSRVLookupHandleUnlocked(PVRSRV_HANDLE_BASE *psBase, void **ppvData, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType, IMG_BOOL bRef);
PVRSRV_ERROR PVRSRVLookupSubHandle(PVRSRV_HANDLE_BASE *psBase, void **ppvData, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType, IMG_HANDLE hAncestor);
void PVRSRVReleaseHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType);
void PVRSRVReleaseHandleUnlocked(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType);
PVRSRV_ERROR PVRSRVDestroyHandle(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType);
PVRSRV_ERROR PVRSRVDestroyHandleUnlocked(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType);
PVRSRV_ERROR PVRSRVDestroyHandleStagedUnlocked(PVRSRV_HANDLE_BASE *psBase, IMG_HANDLE hHandle, PVRSRV_HANDLE_TYPE eType);
PVRSRV_ERROR PVRSRVPurgeHandles(PVRSRV_HANDLE_BASE *psBase);
PVRSRV_ERROR PVRSRVAllocHandleBase(PVRSRV_HANDLE_BASE **ppsBase,
PVRSRV_HANDLE_BASE_TYPE eType);
PVRSRV_ERROR PVRSRVFreeHandleBase(PVRSRV_HANDLE_BASE *psBase, IMG_UINT64 ui64MaxBridgeTime);
PVRSRV_ERROR PVRSRVFreeKernelHandles(PVRSRV_HANDLE_BASE *psBase);
PVRSRV_ERROR PVRSRVHandleInit(void);
PVRSRV_ERROR PVRSRVHandleDeInit(void);
PVRSRV_ERROR PVRSRVAcquireProcessHandleBase(PROCESS_HANDLE_BASE **ppsBase);
PVRSRV_ERROR PVRSRVReleaseProcessHandleBase(PROCESS_HANDLE_BASE *psBase, IMG_UINT64 ui64MaxBridgeTime);
void LockHandle(PVRSRV_HANDLE_BASE *psBase);
void UnlockHandle(PVRSRV_HANDLE_BASE *psBase);
#endif /* !defined(HANDLE_API_H) */

View File

@@ -0,0 +1,417 @@
/*************************************************************************/ /*!
@File
@Title Resource Handle Manager - IDR Back-end
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Provide IDR based resource handle management back-end
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /***************************************************************************/
#include <linux/kernel.h>
#include <linux/err.h>
#include <linux/gfp.h>
#include <linux/idr.h>
#include <linux/pid.h>
#include "handle_impl.h"
#include "allocmem.h"
#include "osfunc.h"
#include "pvr_debug.h"
#define ID_VALUE_MIN 1
#define ID_VALUE_MAX INT_MAX
#define ID_TO_HANDLE(i) ((IMG_HANDLE)(uintptr_t)(i))
#define HANDLE_TO_ID(h) ((IMG_INT)(uintptr_t)(h))
struct _HANDLE_IMPL_BASE_
{
struct idr sIdr;
IMG_UINT32 ui32MaxHandleValue;
IMG_UINT32 ui32TotalHandCount;
};
typedef struct _HANDLE_ITER_DATA_WRAPPER_
{
PFN_HANDLE_ITER pfnHandleIter;
void *pvHandleIterData;
} HANDLE_ITER_DATA_WRAPPER;
static int HandleIterFuncWrapper(int id, void *data, void *iter_data)
{
HANDLE_ITER_DATA_WRAPPER *psIterData = (HANDLE_ITER_DATA_WRAPPER *)iter_data;
PVR_UNREFERENCED_PARAMETER(data);
return (int)psIterData->pfnHandleIter(ID_TO_HANDLE(id), psIterData->pvHandleIterData);
}
/*!
******************************************************************************
@Function AcquireHandle
@Description Acquire a new handle
@Input psBase - Pointer to handle base structure
phHandle - Points to a handle pointer
pvData - Pointer to resource to be associated with the handle
@Output phHandle - Points to a handle pointer
@Return Error code or PVRSRV_OK
******************************************************************************/
static PVRSRV_ERROR AcquireHandle(HANDLE_IMPL_BASE *psBase,
IMG_HANDLE *phHandle,
void *pvData)
{
int id;
int result;
PVR_ASSERT(psBase != NULL);
PVR_ASSERT(phHandle != NULL);
PVR_ASSERT(pvData != NULL);
idr_preload(GFP_KERNEL);
id = idr_alloc(&psBase->sIdr, pvData, ID_VALUE_MIN, psBase->ui32MaxHandleValue + 1, 0);
idr_preload_end();
result = id;
if (result < 0)
{
if (result == -ENOSPC)
{
PVR_DPF((PVR_DBG_ERROR, "%s: Limit of %u handles reached",
__func__, psBase->ui32MaxHandleValue));
return PVRSRV_ERROR_UNABLE_TO_ADD_HANDLE;
}
return PVRSRV_ERROR_OUT_OF_MEMORY;
}
psBase->ui32TotalHandCount++;
*phHandle = ID_TO_HANDLE(id);
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function ReleaseHandle
@Description Release a handle that is no longer needed.
@Input psBase - Pointer to handle base structure
hHandle - Handle to release
ppvData - Points to a void data pointer
@Output ppvData - Points to a void data pointer
@Return PVRSRV_OK or PVRSRV_ERROR
******************************************************************************/
static PVRSRV_ERROR ReleaseHandle(HANDLE_IMPL_BASE *psBase,
IMG_HANDLE hHandle,
void **ppvData)
{
int id = HANDLE_TO_ID(hHandle);
void *pvData;
PVR_ASSERT(psBase);
/* Get the data associated with the handle. If we get back NULL then
it's an invalid handle */
pvData = idr_find(&psBase->sIdr, id);
if (likely(pvData))
{
idr_remove(&psBase->sIdr, id);
psBase->ui32TotalHandCount--;
}
if (unlikely(pvData == NULL))
{
PVR_DPF((PVR_DBG_ERROR, "%s: Handle out of range (%u > %u)",
__func__, id, psBase->ui32TotalHandCount));
return PVRSRV_ERROR_HANDLE_INDEX_OUT_OF_RANGE;
}
if (ppvData)
{
*ppvData = pvData;
}
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function GetHandleData
@Description Get the data associated with the given handle
@Input psBase - Pointer to handle base structure
hHandle - Handle from which data should be retrieved
ppvData - Points to a void data pointer
@Output ppvData - Points to a void data pointer
@Return Error code or PVRSRV_OK
******************************************************************************/
static PVRSRV_ERROR GetHandleData(HANDLE_IMPL_BASE *psBase,
IMG_HANDLE hHandle,
void **ppvData)
{
int id = HANDLE_TO_ID(hHandle);
void *pvData;
PVR_ASSERT(psBase);
PVR_ASSERT(ppvData);
pvData = idr_find(&psBase->sIdr, id);
if (likely(pvData))
{
*ppvData = pvData;
return PVRSRV_OK;
}
else
{
return PVRSRV_ERROR_HANDLE_INDEX_OUT_OF_RANGE;
}
}
/*!
******************************************************************************
@Function SetHandleData
@Description Set the data associated with the given handle
@Input psBase - Pointer to handle base structure
hHandle - Handle for which data should be changed
pvData - Pointer to new data to be associated with the handle
@Return Error code or PVRSRV_OK
******************************************************************************/
static PVRSRV_ERROR SetHandleData(HANDLE_IMPL_BASE *psBase,
IMG_HANDLE hHandle,
void *pvData)
{
int id = HANDLE_TO_ID(hHandle);
void *pvOldData;
PVR_ASSERT(psBase);
pvOldData = idr_replace(&psBase->sIdr, pvData, id);
if (IS_ERR(pvOldData))
{
if (PTR_ERR(pvOldData) == -ENOENT)
{
return PVRSRV_ERROR_HANDLE_NOT_ALLOCATED;
}
else
{
return PVRSRV_ERROR_HANDLE_INDEX_OUT_OF_RANGE;
}
}
return PVRSRV_OK;
}
static PVRSRV_ERROR IterateOverHandles(HANDLE_IMPL_BASE *psBase, PFN_HANDLE_ITER pfnHandleIter, void *pvHandleIterData)
{
HANDLE_ITER_DATA_WRAPPER sIterData;
PVR_ASSERT(psBase);
PVR_ASSERT(pfnHandleIter);
sIterData.pfnHandleIter = pfnHandleIter;
sIterData.pvHandleIterData = pvHandleIterData;
return (PVRSRV_ERROR)idr_for_each(&psBase->sIdr, HandleIterFuncWrapper, &sIterData);
}
/*!
******************************************************************************
@Function EnableHandlePurging
@Description Enable purging for a given handle base
@Input psBase - pointer to handle base structure
@Return Error code or PVRSRV_OK
******************************************************************************/
static PVRSRV_ERROR EnableHandlePurging(HANDLE_IMPL_BASE *psBase)
{
PVR_UNREFERENCED_PARAMETER(psBase);
PVR_ASSERT(psBase);
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function PurgeHandles
@Description Purge handles for a given handle base
@Input psBase - Pointer to handle base structure
@Return Error code or PVRSRV_OK
******************************************************************************/
static PVRSRV_ERROR PurgeHandles(HANDLE_IMPL_BASE *psBase)
{
PVR_UNREFERENCED_PARAMETER(psBase);
PVR_ASSERT(psBase);
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function CreateHandleBase
@Description Create a handle base structure
@Input ppsBase - pointer to handle base structure pointer
@Output ppsBase - points to handle base structure pointer
@Return Error code or PVRSRV_OK
******************************************************************************/
static PVRSRV_ERROR CreateHandleBase(HANDLE_IMPL_BASE **ppsBase)
{
HANDLE_IMPL_BASE *psBase;
PVR_ASSERT(ppsBase);
psBase = OSAllocZMem(sizeof(*psBase));
if (psBase == NULL)
{
PVR_DPF((PVR_DBG_ERROR, "%s: Couldn't allocate generic handle base",
__func__));
return PVRSRV_ERROR_OUT_OF_MEMORY;
}
idr_init(&psBase->sIdr);
psBase->ui32MaxHandleValue = ID_VALUE_MAX;
psBase->ui32TotalHandCount = 0;
*ppsBase = psBase;
return PVRSRV_OK;
}
/*!
******************************************************************************
@Function DestroyHandleBase
@Description Destroy a handle base structure
@Input psBase - pointer to handle base structure
@Return Error code or PVRSRV_OK
******************************************************************************/
static PVRSRV_ERROR DestroyHandleBase(HANDLE_IMPL_BASE *psBase)
{
PVR_ASSERT(psBase);
/* Finally destroy the idr */
idr_destroy(&psBase->sIdr);
OSFreeMem(psBase);
return PVRSRV_OK;
}
static const HANDLE_IMPL_FUNCTAB g_sHandleFuncTab =
{
.pfnAcquireHandle = AcquireHandle,
.pfnReleaseHandle = ReleaseHandle,
.pfnGetHandleData = GetHandleData,
.pfnSetHandleData = SetHandleData,
.pfnIterateOverHandles = IterateOverHandles,
.pfnEnableHandlePurging = EnableHandlePurging,
.pfnPurgeHandles = PurgeHandles,
.pfnCreateHandleBase = CreateHandleBase,
.pfnDestroyHandleBase = DestroyHandleBase,
};
PVRSRV_ERROR PVRSRVHandleGetFuncTable(HANDLE_IMPL_FUNCTAB const **ppsFuncs)
{
static IMG_BOOL bAcquired = IMG_FALSE;
if (bAcquired)
{
PVR_DPF((PVR_DBG_ERROR, "%s: Function table already acquired",
__func__));
return PVRSRV_ERROR_RESOURCE_UNAVAILABLE;
}
if (ppsFuncs == NULL)
{
return PVRSRV_ERROR_INVALID_PARAMS;
}
*ppsFuncs = &g_sHandleFuncTab;
bAcquired = IMG_TRUE;
return PVRSRV_OK;
}

View File

@@ -0,0 +1,90 @@
/**************************************************************************/ /*!
@File
@Title Implementation Callbacks for Handle Manager API
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Part of the handle manager API. This file is for declarations
and definitions that are private/internal to the handle manager
API but need to be shared between the generic handle manager
code and the various handle manager backends, i.e. the code that
implements the various callbacks.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /***************************************************************************/
#if !defined(HANDLE_IMPL_H)
#define HANDLE_IMPL_H
#include "img_types.h"
#include "pvrsrv_error.h"
typedef struct _HANDLE_IMPL_BASE_ HANDLE_IMPL_BASE;
typedef PVRSRV_ERROR (*PFN_HANDLE_ITER)(IMG_HANDLE hHandle, void *pvData);
typedef struct _HANDLE_IMPL_FUNCTAB_
{
/* Acquire a new handle which is associated with the given data */
PVRSRV_ERROR (*pfnAcquireHandle)(HANDLE_IMPL_BASE *psHandleBase, IMG_HANDLE *phHandle, void *pvData);
/* Release the given handle (optionally returning the data associated with it) */
PVRSRV_ERROR (*pfnReleaseHandle)(HANDLE_IMPL_BASE *psHandleBase, IMG_HANDLE hHandle, void **ppvData);
/* Get the data associated with the given handle */
PVRSRV_ERROR (*pfnGetHandleData)(HANDLE_IMPL_BASE *psHandleBase, IMG_HANDLE hHandle, void **ppvData);
/* Set the data associated with the given handle */
PVRSRV_ERROR (*pfnSetHandleData)(HANDLE_IMPL_BASE *psHandleBase, IMG_HANDLE hHandle, void *pvData);
PVRSRV_ERROR (*pfnIterateOverHandles)(HANDLE_IMPL_BASE *psHandleBase, PFN_HANDLE_ITER pfnHandleIter, void *pvHandleIterData);
/* Enable handle purging on the given handle base */
PVRSRV_ERROR (*pfnEnableHandlePurging)(HANDLE_IMPL_BASE *psHandleBase);
/* Purge handles on the given handle base */
PVRSRV_ERROR (*pfnPurgeHandles)(HANDLE_IMPL_BASE *psHandleBase);
/* Create handle base */
PVRSRV_ERROR (*pfnCreateHandleBase)(HANDLE_IMPL_BASE **psHandleBase);
/* Destroy handle base */
PVRSRV_ERROR (*pfnDestroyHandleBase)(HANDLE_IMPL_BASE *psHandleBase);
} HANDLE_IMPL_FUNCTAB;
PVRSRV_ERROR PVRSRVHandleGetFuncTable(HANDLE_IMPL_FUNCTAB const **ppsFuncs);
#endif /* !defined(HANDLE_IMPL_H) */

View File

@@ -0,0 +1,87 @@
/**************************************************************************/ /*!
@File
@Title Handle Manager handle types
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Provide handle management
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /***************************************************************************/
/* NOTE: Do not add include guards to this file */
HANDLETYPE(NONE)
HANDLETYPE(SHARED_EVENT_OBJECT)
HANDLETYPE(EVENT_OBJECT_CONNECT)
HANDLETYPE(PMR_LOCAL_EXPORT_HANDLE)
HANDLETYPE(PHYSMEM_PMR)
HANDLETYPE(PHYSMEM_PMR_EXPORT)
HANDLETYPE(PHYSMEM_PMR_SECURE_EXPORT)
HANDLETYPE(DEVMEMINT_CTX)
HANDLETYPE(DEVMEMINT_CTX_EXPORT)
HANDLETYPE(DEVMEMINT_HEAP)
HANDLETYPE(DEVMEMINT_RESERVATION)
HANDLETYPE(DEVMEMXINT_RESERVATION)
HANDLETYPE(DEVMEMINT_MAPPING)
HANDLETYPE(RGX_FW_MEMDESC)
HANDLETYPE(RGX_FREELIST)
HANDLETYPE(RGX_MEMORY_BLOCK)
HANDLETYPE(RGX_SERVER_RENDER_CONTEXT)
HANDLETYPE(RGX_SERVER_TQ_CONTEXT)
HANDLETYPE(RGX_SERVER_TQ_TDM_CONTEXT)
HANDLETYPE(RGX_SERVER_COMPUTE_CONTEXT)
HANDLETYPE(RGX_SERVER_RAY_CONTEXT)
HANDLETYPE(RGX_SERVER_KICKSYNC_CONTEXT)
HANDLETYPE(SYNC_PRIMITIVE_BLOCK)
HANDLETYPE(SYNC_RECORD_HANDLE)
HANDLETYPE(PVRSRV_TIMELINE_SERVER)
HANDLETYPE(PVRSRV_FENCE_SERVER)
HANDLETYPE(PVRSRV_FENCE_EXPORT)
HANDLETYPE(RGX_KM_HW_RT_DATASET)
HANDLETYPE(RGX_FWIF_ZSBUFFER)
HANDLETYPE(RGX_POPULATION)
HANDLETYPE(DC_DEVICE)
HANDLETYPE(DC_DISPLAY_CONTEXT)
HANDLETYPE(DC_BUFFER)
HANDLETYPE(DC_PIN_HANDLE)
HANDLETYPE(DEVMEM_MEM_IMPORT)
HANDLETYPE(PHYSMEM_PMR_PAGELIST)
HANDLETYPE(PVR_TL_SD)
HANDLETYPE(RI_HANDLE)
HANDLETYPE(DEV_PRIV_DATA)
HANDLETYPE(MM_PLAT_CLEANUP)
HANDLETYPE(WORKEST_RETURN_DATA)
HANDLETYPE(DI_CONTEXT)
HANDLETYPE(PVR_HWPERF_SD)

View File

@@ -0,0 +1,747 @@
/*************************************************************************/ /*!
@File
@Title Self scaling hash tables.
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description
Implements simple self scaling hash tables. Hash collisions are handled by
chaining entries together. Hash tables are increased in size when they
become more than (50%?) full and decreased in size when less than (25%?)
full. Hash tables are never decreased below their initial size.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
/* include/ */
#include "img_defs.h"
#include "img_types.h"
#include "pvr_debug.h"
#include "pvrsrv_error.h"
/* services/shared/include/ */
#include "hash.h"
/* services/client/include/ or services/server/include/ */
#include "osfunc_common.h"
#include "allocmem.h"
//#define PERF_DBG_RESIZE
#if !defined(__KERNEL__) && defined(PERF_DBG_RESIZE)
#include <sys/time.h>
#endif
#if defined(__KERNEL__)
#include "pvrsrv.h"
#endif
#define KEY_TO_INDEX(pHash, key, uSize) \
((pHash)->pfnHashFunc((pHash)->uKeySize, (key), (uSize)) % (uSize))
#define KEY_COMPARE(pHash, pKey1, pKey2) \
((pHash)->pfnKeyComp((pHash)->uKeySize, (pKey1), (pKey2)))
#if defined(__linux__) && defined(__KERNEL__)
#define _AllocMem OSAllocMemNoStats
#define _AllocZMem OSAllocZMemNoStats
#define _FreeMem OSFreeMemNoStats
#else
#define _AllocMem OSAllocMem
#define _AllocZMem OSAllocZMem
#define _FreeMem OSFreeMem
#endif
#define NO_SHRINK 0
/* Each entry in a hash table is placed into a bucket */
typedef struct _BUCKET_
{
struct _BUCKET_ *pNext; /*!< the next bucket on the same chain */
uintptr_t v; /*!< entry value */
uintptr_t k[]; /* PRQA S 0642 */
/* override dynamic array declaration warning */
} BUCKET;
struct _HASH_TABLE_
{
IMG_UINT32 uSize; /*!< current size of the hash table */
IMG_UINT32 uCount; /*!< number of entries currently in the hash table */
IMG_UINT32 uMinimumSize; /*!< the minimum size that the hash table should be re-sized to */
IMG_UINT32 uKeySize; /*!< size of key in bytes */
IMG_UINT32 uShrinkThreshold; /*!< The threshold at which to trigger a shrink */
IMG_UINT32 uGrowThreshold; /*!< The threshold at which to trigger a grow */
HASH_FUNC* pfnHashFunc; /*!< hash function */
HASH_KEY_COMP* pfnKeyComp; /*!< key comparison function */
BUCKET** ppBucketTable; /*!< the hash table array */
#if defined(DEBUG)
const char* pszFile;
unsigned int ui32LineNum;
#endif
};
/*************************************************************************/ /*!
@Function HASH_Func_Default
@Description Hash function intended for hashing keys composed of uintptr_t
arrays.
@Input uKeySize The size of the hash key, in bytes.
@Input pKey A pointer to the key to hash.
@Input uHashTabLen The length of the hash table.
@Return The hash value.
*/ /**************************************************************************/
IMG_INTERNAL IMG_UINT32
HASH_Func_Default(size_t uKeySize, void *pKey, IMG_UINT32 uHashTabLen)
{
uintptr_t *p = (uintptr_t *)pKey;
IMG_UINT32 uKeyLen = uKeySize / sizeof(uintptr_t);
IMG_UINT32 ui;
IMG_UINT32 uHashKey = 0;
PVR_UNREFERENCED_PARAMETER(uHashTabLen);
PVR_ASSERT((uKeySize % sizeof(uintptr_t)) == 0);
for (ui = 0; ui < uKeyLen; ui++)
{
IMG_UINT32 uHashPart = (IMG_UINT32)*p++;
uHashPart += (uHashPart << 12);
uHashPart ^= (uHashPart >> 22);
uHashPart += (uHashPart << 4);
uHashPart ^= (uHashPart >> 9);
uHashPart += (uHashPart << 10);
uHashPart ^= (uHashPart >> 2);
uHashPart += (uHashPart << 7);
uHashPart ^= (uHashPart >> 12);
uHashKey += uHashPart;
}
return uHashKey;
}
/*************************************************************************/ /*!
@Function HASH_Key_Comp_Default
@Description Compares keys composed of uintptr_t arrays.
@Input uKeySize The size of the hash key, in bytes.
@Input pKey1 Pointer to first hash key to compare.
@Input pKey2 Pointer to second hash key to compare.
@Return IMG_TRUE - The keys match.
IMG_FALSE - The keys don't match.
*/ /**************************************************************************/
IMG_INTERNAL IMG_BOOL
HASH_Key_Comp_Default(size_t uKeySize, void *pKey1, void *pKey2)
{
uintptr_t *p1 = (uintptr_t *)pKey1;
uintptr_t *p2 = (uintptr_t *)pKey2;
IMG_UINT32 uKeyLen = uKeySize / sizeof(uintptr_t);
IMG_UINT32 ui;
PVR_ASSERT((uKeySize % sizeof(uintptr_t)) == 0);
for (ui = 0; ui < uKeyLen; ui++)
{
if (*p1++ != *p2++)
return IMG_FALSE;
}
return IMG_TRUE;
}
/*************************************************************************/ /*!
@Function _ChainInsert
@Description Insert a bucket into the appropriate hash table chain.
@Input pBucket The bucket
@Input ppBucketTable The hash table
@Input uSize The size of the hash table
@Return PVRSRV_ERROR
*/ /**************************************************************************/
static void
_ChainInsert(HASH_TABLE *pHash, BUCKET *pBucket, BUCKET **ppBucketTable, IMG_UINT32 uSize)
{
IMG_UINT32 uIndex;
/* We assume that all parameters passed by the caller are valid. */
PVR_ASSERT(pBucket != NULL);
PVR_ASSERT(ppBucketTable != NULL);
PVR_ASSERT(uSize != 0);
uIndex = KEY_TO_INDEX(pHash, pBucket->k, uSize); /* PRQA S 0432,0541 */ /* ignore dynamic array warning */
pBucket->pNext = ppBucketTable[uIndex];
ppBucketTable[uIndex] = pBucket;
}
/*************************************************************************/ /*!
@Function _Rehash
@Description Iterate over every entry in an old hash table and rehash into
the new table.
@Input ppOldTable The old hash table
@Input uOldSize The size of the old hash table
@Input ppNewTable The new hash table
@Input uNewSize The size of the new hash table
@Return None
*/ /**************************************************************************/
static void
_Rehash(HASH_TABLE *pHash,
BUCKET **ppOldTable, IMG_UINT32 uOldSize,
BUCKET **ppNewTable, IMG_UINT32 uNewSize)
{
IMG_UINT32 uIndex;
for (uIndex=0; uIndex< uOldSize; uIndex++)
{
BUCKET *pBucket;
pBucket = ppOldTable[uIndex];
while (pBucket != NULL)
{
BUCKET *pNextBucket = pBucket->pNext;
_ChainInsert(pHash, pBucket, ppNewTable, uNewSize);
pBucket = pNextBucket;
}
}
}
/*************************************************************************/ /*!
@Function _Resize
@Description Attempt to resize a hash table, failure to allocate a new
larger hash table is not considered a hard failure. We simply
continue and allow the table to fill up, the effect is to
allow hash chains to become longer.
@Input pHash Hash table to resize.
@Input uNewSize Required table size.
@Return IMG_TRUE Success
IMG_FALSE Failed
*/ /**************************************************************************/
static IMG_BOOL
_Resize(HASH_TABLE *pHash, IMG_UINT32 uNewSize)
{
BUCKET **ppNewTable;
IMG_UINT32 uiThreshold = uNewSize >> 2;
#if !defined(__KERNEL__) && defined(PERF_DBG_RESIZE)
struct timeval start, end;
#endif
if (uNewSize == pHash->uSize)
{
return IMG_TRUE;
}
#if !defined(__KERNEL__) && defined(PERF_DBG_RESIZE)
gettimeofday(&start, NULL);
#endif
ppNewTable = _AllocZMem(sizeof(BUCKET *) * uNewSize);
if (ppNewTable == NULL)
{
return IMG_FALSE;
}
_Rehash(pHash, pHash->ppBucketTable, pHash->uSize, ppNewTable, uNewSize);
_FreeMem(pHash->ppBucketTable);
#if !defined(__KERNEL__) && defined(PERF_DBG_RESIZE)
gettimeofday(&end, NULL);
if (start.tv_usec > end.tv_usec)
{
end.tv_usec = 1000000 - start.tv_usec + end.tv_usec;
}
else
{
end.tv_usec -= start.tv_usec;
}
PVR_DPF((PVR_DBG_ERROR, "%s: H:%p O:%d N:%d C:%d G:%d S:%d T:%06luus", __func__, pHash, pHash->uSize, uNewSize, pHash->uCount, pHash->uGrowThreshold, pHash->uShrinkThreshold, end.tv_usec));
#endif
/*not nulling pointer, being reassigned just below*/
pHash->ppBucketTable = ppNewTable;
pHash->uSize = uNewSize;
pHash->uGrowThreshold = uiThreshold * 3;
pHash->uShrinkThreshold = (uNewSize <= pHash->uMinimumSize) ? NO_SHRINK : uiThreshold;
return IMG_TRUE;
}
/*************************************************************************/ /*!
@Function HASH_Create_Extended
@Description Create a self scaling hash table, using the supplied key size,
and the supplied hash and key comparison functions.
@Input uInitialLen Initial and minimum length of the hash table,
where the length refers to the number of entries
in the hash table, not its size in bytes.
@Input uKeySize The size of the key, in bytes.
@Input pfnHashFunc Pointer to hash function.
@Input pfnKeyComp Pointer to key comparison function.
@Return NULL or hash table handle.
*/ /**************************************************************************/
IMG_INTERNAL
HASH_TABLE * HASH_Create_Extended_Int (IMG_UINT32 uInitialLen, size_t uKeySize, HASH_FUNC *pfnHashFunc, HASH_KEY_COMP *pfnKeyComp)
{
HASH_TABLE *pHash;
if (uInitialLen == 0 || uKeySize == 0 || pfnHashFunc == NULL || pfnKeyComp == NULL)
{
PVR_DPF((PVR_DBG_ERROR, "%s: invalid input parameters", __func__));
return NULL;
}
PVR_DPF((PVR_DBG_MESSAGE, "%s: InitialSize=0x%x", __func__, uInitialLen));
pHash = _AllocMem(sizeof(HASH_TABLE));
if (pHash == NULL)
{
return NULL;
}
pHash->uCount = 0;
pHash->uSize = uInitialLen;
pHash->uMinimumSize = uInitialLen;
pHash->uKeySize = uKeySize;
pHash->uGrowThreshold = (uInitialLen >> 2) * 3;
pHash->uShrinkThreshold = NO_SHRINK;
pHash->pfnHashFunc = pfnHashFunc;
pHash->pfnKeyComp = pfnKeyComp;
pHash->ppBucketTable = _AllocZMem(sizeof(BUCKET *) * pHash->uSize);
if (pHash->ppBucketTable == NULL)
{
_FreeMem(pHash);
/*not nulling pointer, out of scope*/
return NULL;
}
return pHash;
}
#if defined(DEBUG)
IMG_INTERNAL
HASH_TABLE * HASH_Create_Extended_Debug (IMG_UINT32 uInitialLen, size_t uKeySize, HASH_FUNC *pfnHashFunc, HASH_KEY_COMP *pfnKeyComp,
const char *file, const unsigned int line)
{
HASH_TABLE *hash;
hash = HASH_Create_Extended_Int(uInitialLen, uKeySize,
pfnHashFunc, pfnKeyComp);
if (hash)
{
hash->pszFile = file;
hash->ui32LineNum = line;
}
return hash;
}
#endif
/*************************************************************************/ /*!
@Function HASH_Create
@Description Create a self scaling hash table with a key consisting of a
single uintptr_t, and using the default hash and key
comparison functions.
@Input uInitialLen Initial and minimum length of the hash table,
where the length refers to the number of entries
in the hash table, not its size in bytes.
@Return NULL or hash table handle.
*/ /**************************************************************************/
IMG_INTERNAL
HASH_TABLE * HASH_Create_Int (IMG_UINT32 uInitialLen)
{
return HASH_Create_Extended_Int(uInitialLen, sizeof(uintptr_t),
&HASH_Func_Default, &HASH_Key_Comp_Default);
}
#if defined(DEBUG)
IMG_INTERNAL
HASH_TABLE * HASH_Create_Debug(IMG_UINT32 uInitialLen, const char *file, const unsigned int line)
{
HASH_TABLE *hash;
hash = HASH_Create_Extended_Int(uInitialLen, sizeof(uintptr_t),
&HASH_Func_Default, &HASH_Key_Comp_Default);
if (hash)
{
hash->pszFile = file;
hash->ui32LineNum = line;
}
return hash;
}
#endif
/*************************************************************************/ /*!
@Function HASH_Delete_Extended
@Description Delete a hash table created by HASH_Create_Extended or
HASH_Create. All entries in the table should have been removed
before calling this function.
@Input pHash Hash table
@Input bWarn Set false to suppress warnings in the case of
deletion with active entries.
*/ /**************************************************************************/
IMG_INTERNAL void
HASH_Delete_Extended(HASH_TABLE *pHash, IMG_BOOL bWarn)
{
IMG_BOOL bDoCheck = IMG_TRUE;
#if defined(__KERNEL__) && !defined(__QNXNTO__)
PVRSRV_DATA *psPVRSRVData = PVRSRVGetPVRSRVData();
if (psPVRSRVData != NULL)
{
if (psPVRSRVData->eServicesState != PVRSRV_SERVICES_STATE_OK)
{
bDoCheck = IMG_FALSE;
}
}
#if defined(PVRSRV_FORCE_UNLOAD_IF_BAD_STATE)
else
{
bDoCheck = IMG_FALSE;
}
#endif
#endif
if (pHash != NULL)
{
PVR_DPF((PVR_DBG_MESSAGE, "HASH_Delete"));
if (bDoCheck)
{
PVR_ASSERT(pHash->uCount==0);
}
if (pHash->uCount != 0)
{
IMG_UINT32 i;
if (bWarn)
{
PVR_DPF((PVR_DBG_ERROR, "%s: Leak detected in hash table!", __func__));
PVR_DPF((PVR_DBG_ERROR, "%s: Likely Cause: client drivers not freeing allocations before destroying devmem context", __func__));
PVR_DPF((PVR_DBG_ERROR, "%s: Removing remaining %u hash entries.", __func__, pHash->uCount));
#if defined(DEBUG)
PVR_DPF ((PVR_DBG_ERROR, "%s: Hash %p created at %s:%u.", __func__, (uintptr_t*)pHash, pHash->pszFile, pHash->ui32LineNum));
#endif
}
for (i = 0; i < pHash->uSize; i++)
{
BUCKET *pBucket = pHash->ppBucketTable[i];
while (pBucket != NULL)
{
BUCKET *pNextBucket = pBucket->pNext;
_FreeMem(pBucket);
pBucket = pNextBucket;
}
}
}
_FreeMem(pHash->ppBucketTable);
pHash->ppBucketTable = NULL;
_FreeMem(pHash);
/*not nulling pointer, copy on stack*/
}
}
/*************************************************************************/ /*!
@Function HASH_Delete
@Description Delete a hash table created by HASH_Create_Extended or
HASH_Create. All entries in the table must have been removed
before calling this function.
@Input pHash Hash table
*/ /**************************************************************************/
IMG_INTERNAL void
HASH_Delete(HASH_TABLE *pHash)
{
HASH_Delete_Extended(pHash, IMG_TRUE);
}
/*************************************************************************/ /*!
@Function HASH_Insert_Extended
@Description Insert a key value pair into a hash table created with
HASH_Create_Extended.
@Input pHash The hash table.
@Input pKey Pointer to the key.
@Input v The value associated with the key.
@Return IMG_TRUE - success.
IMG_FALSE - failure.
*/ /**************************************************************************/
IMG_INTERNAL IMG_BOOL
HASH_Insert_Extended(HASH_TABLE *pHash, void *pKey, uintptr_t v)
{
BUCKET *pBucket;
PVR_ASSERT(pHash != NULL);
if (pHash == NULL)
{
PVR_DPF((PVR_DBG_ERROR, "%s: invalid parameter", __func__));
return IMG_FALSE;
}
pBucket = _AllocMem(sizeof(BUCKET) + pHash->uKeySize);
if (pBucket == NULL)
{
return IMG_FALSE;
}
pBucket->v = v;
/* PRQA S 0432,0541 1 */ /* ignore warning about dynamic array k (linux)*/
OSCachedMemCopy(pBucket->k, pKey, pHash->uKeySize);
_ChainInsert(pHash, pBucket, pHash->ppBucketTable, pHash->uSize);
pHash->uCount++;
/* check if we need to think about re-balancing */
if (pHash->uCount > pHash->uGrowThreshold)
{
/* Ignore the return code from _Resize because the hash table is
still in a valid state and although not ideally sized, it is still
functional */
_Resize(pHash, pHash->uSize << 1);
}
return IMG_TRUE;
}
/*************************************************************************/ /*!
@Function HASH_Insert
@Description Insert a key value pair into a hash table created with
HASH_Create.
@Input pHash The hash table.
@Input k The key value.
@Input v The value associated with the key.
@Return IMG_TRUE - success.
IMG_FALSE - failure.
*/ /**************************************************************************/
IMG_INTERNAL IMG_BOOL
HASH_Insert(HASH_TABLE *pHash, uintptr_t k, uintptr_t v)
{
return HASH_Insert_Extended(pHash, &k, v);
}
/*************************************************************************/ /*!
@Function HASH_Remove_Extended
@Description Remove a key from a hash table created with
HASH_Create_Extended.
@Input pHash The hash table.
@Input pKey Pointer to key.
@Return 0 if the key is missing, or the value associated with the key.
*/ /**************************************************************************/
IMG_INTERNAL uintptr_t
HASH_Remove_Extended(HASH_TABLE *pHash, void *pKey)
{
BUCKET **ppBucket;
IMG_UINT32 uIndex;
PVR_ASSERT(pHash != NULL);
if (pHash == NULL)
{
PVR_DPF((PVR_DBG_ERROR, "%s: Null hash table", __func__));
return 0;
}
uIndex = KEY_TO_INDEX(pHash, pKey, pHash->uSize);
for (ppBucket = &(pHash->ppBucketTable[uIndex]); *ppBucket != NULL; ppBucket = &((*ppBucket)->pNext))
{
/* PRQA S 0432,0541 1 */ /* ignore warning about dynamic array k */
if (KEY_COMPARE(pHash, (*ppBucket)->k, pKey))
{
BUCKET *pBucket = *ppBucket;
uintptr_t v = pBucket->v;
(*ppBucket) = pBucket->pNext;
_FreeMem(pBucket);
/*not nulling original pointer, already overwritten*/
pHash->uCount--;
/* check if we need to think about re-balancing, when the shrink
* threshold is 0 we are at the minimum size, no further shrink */
if (pHash->uCount < pHash->uShrinkThreshold)
{
/* Ignore the return code from _Resize because the
hash table is still in a valid state and although
not ideally sized, it is still functional */
_Resize(pHash, MAX(pHash->uSize >> 1, pHash->uMinimumSize));
}
return v;
}
}
return 0;
}
/*************************************************************************/ /*!
@Function HASH_Remove
@Description Remove a key value pair from a hash table created with
HASH_Create.
@Input pHash The hash table.
@Input pKey Pointer to key.
@Return 0 if the key is missing, or the value associated with the key.
*/ /**************************************************************************/
IMG_INTERNAL uintptr_t
HASH_Remove(HASH_TABLE *pHash, uintptr_t k)
{
return HASH_Remove_Extended(pHash, &k);
}
/*************************************************************************/ /*!
@Function HASH_Retrieve_Extended
@Description Retrieve a value from a hash table created with
HASH_Create_Extended.
@Input pHash The hash table.
@Input pKey Pointer to key.
@Return 0 if the key is missing, or the value associated with the key.
*/ /**************************************************************************/
IMG_INTERNAL uintptr_t
HASH_Retrieve_Extended(HASH_TABLE *pHash, void *pKey)
{
BUCKET **ppBucket;
IMG_UINT32 uIndex;
PVR_ASSERT(pHash != NULL);
if (pHash == NULL)
{
PVR_DPF((PVR_DBG_ERROR, "%s: Null hash table", __func__));
return 0;
}
uIndex = KEY_TO_INDEX(pHash, pKey, pHash->uSize);
for (ppBucket = &(pHash->ppBucketTable[uIndex]); *ppBucket != NULL; ppBucket = &((*ppBucket)->pNext))
{
/* PRQA S 0432,0541 1 */ /* ignore warning about dynamic array k */
if (KEY_COMPARE(pHash, (*ppBucket)->k, pKey))
{
BUCKET *pBucket = *ppBucket;
uintptr_t v = pBucket->v;
return v;
}
}
return 0;
}
/*************************************************************************/ /*!
@Function HASH_Retrieve
@Description Retrieve a value from a hash table created with HASH_Create.
@Input pHash The hash table.
@Input pKey Pointer to key.
@Return 0 if the key is missing, or the value associated with the key.
*/ /**************************************************************************/
IMG_INTERNAL uintptr_t
HASH_Retrieve(HASH_TABLE *pHash, uintptr_t k)
{
return HASH_Retrieve_Extended(pHash, &k);
}
/*************************************************************************/ /*!
@Function HASH_Iterate
@Description Iterate over every entry in the hash table.
@Input pHash Hash table to iterate.
@Input pfnCallback Callback to call with the key and data for each
. entry in the hash table
@Return Callback error if any, otherwise PVRSRV_OK
*/ /**************************************************************************/
IMG_INTERNAL PVRSRV_ERROR
HASH_Iterate(HASH_TABLE *pHash, HASH_pfnCallback pfnCallback, void* args)
{
IMG_UINT32 uIndex;
for (uIndex=0; uIndex < pHash->uSize; uIndex++)
{
BUCKET *pBucket;
pBucket = pHash->ppBucketTable[uIndex];
while (pBucket != NULL)
{
PVRSRV_ERROR eError;
BUCKET *pNextBucket = pBucket->pNext;
eError = pfnCallback((uintptr_t) ((void *) *(pBucket->k)), pBucket->v, args);
/* The callback might want us to break out early */
if (eError != PVRSRV_OK)
return eError;
pBucket = pNextBucket;
}
}
return PVRSRV_OK;
}
/*************************************************************************/ /*!
@Function HASH_Count
@Description Retrieve the number of entries in the hash table.
@Input pHash The hash table.
@Return The number of entries.
*/ /**************************************************************************/
IMG_INTERNAL IMG_UINT32
HASH_Count(HASH_TABLE *pHash)
{
return pHash->uCount;
}
#ifdef HASH_TRACE
/*************************************************************************/ /*!
@Function HASH_Dump
@Description Dump out some information about a hash table.
@Input pHash The hash table.
*/ /**************************************************************************/
void
HASH_Dump(HASH_TABLE *pHash)
{
IMG_UINT32 uIndex;
IMG_UINT32 uMaxLength=0;
IMG_UINT32 uEmptyCount=0;
PVR_ASSERT(pHash != NULL);
for (uIndex=0; uIndex<pHash->uSize; uIndex++)
{
BUCKET *pBucket;
IMG_UINT32 uLength = 0;
if (pHash->ppBucketTable[uIndex] == NULL)
{
uEmptyCount++;
}
for (pBucket=pHash->ppBucketTable[uIndex];
pBucket != NULL;
pBucket = pBucket->pNext)
{
uLength++;
}
uMaxLength = MAX(uMaxLength, uLength);
}
PVR_TRACE(("hash table: uMinimumSize=%d size=%d count=%d",
pHash->uMinimumSize, pHash->uSize, pHash->uCount));
PVR_TRACE((" empty=%d max=%d", uEmptyCount, uMaxLength));
}
#endif

View File

@@ -0,0 +1,255 @@
/*************************************************************************/ /*!
@File
@Title Self scaling hash tables
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Implements simple self scaling hash tables.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#ifndef HASH_H
#define HASH_H
#include "img_types.h"
#include "pvrsrv_error.h"
#if defined(__cplusplus)
extern "C" {
#endif
/*
* Keys passed to the comparison function are only guaranteed to be aligned on
* an uintptr_t boundary.
*/
typedef IMG_UINT32 HASH_FUNC(size_t uKeySize, void *pKey, IMG_UINT32 uHashTabLen);
typedef IMG_BOOL HASH_KEY_COMP(size_t uKeySize, void *pKey1, void *pKey2);
typedef struct _HASH_TABLE_ HASH_TABLE;
typedef PVRSRV_ERROR (*HASH_pfnCallback) (
uintptr_t k,
uintptr_t v,
void* pvPriv
);
#if defined(DEBUG)
#else
#define HASH_CREATE(LEN) HASH_Create(LEN)
#endif
/*************************************************************************/ /*!
@Function HASH_Func_Default
@Description Hash function intended for hashing keys composed of uintptr_t
arrays.
@Input uKeySize The size of the hash key, in bytes.
@Input pKey A pointer to the key to hash.
@Input uHashTabLen The length of the hash table.
@Return The hash value.
*/ /**************************************************************************/
IMG_UINT32 HASH_Func_Default(size_t uKeySize, void *pKey, IMG_UINT32 uHashTabLen);
/*************************************************************************/ /*!
@Function HASH_Key_Comp_Default
@Description Compares keys composed of uintptr_t arrays.
@Input uKeySize The size of the hash key, in bytes.
@Input pKey1 Pointer to first hash key to compare.
@Input pKey2 Pointer to second hash key to compare.
@Return IMG_TRUE - The keys match.
IMG_FALSE - The keys don't match.
*/ /**************************************************************************/
IMG_BOOL HASH_Key_Comp_Default(size_t uKeySize, void *pKey1, void *pKey2);
/*************************************************************************/ /*!
@Function HASH_Create_Extended
@Description Create a self scaling hash table, using the supplied key size,
and the supplied hash and key comparison functions.
@Input uInitialLen Initial and minimum length of the hash table,
where the length refers to the number of entries
in the hash table, not its size in bytes.
@Input uKeySize The size of the key, in bytes.
@Input pfnHashFunc Pointer to hash function.
@Input pfnKeyComp Pointer to key comparison function.
@Return NULL or hash table handle.
*/ /**************************************************************************/
HASH_TABLE * HASH_Create_Extended_Int(IMG_UINT32 uInitialLen, size_t uKeySize, HASH_FUNC *pfnHashFunc, HASH_KEY_COMP *pfnKeyComp);
#if defined(DEBUG)
#define HASH_Create_Extended(LEN, KS, FUN, CMP) HASH_Create_Extended_Debug(LEN, KS, FUN, CMP, __FILE__, __LINE__)
HASH_TABLE * HASH_Create_Extended_Debug (IMG_UINT32 uInitialLen, size_t uKeySize, HASH_FUNC *pfnHashFunc, HASH_KEY_COMP *pfnKeyComp,
const char *file, const unsigned int line);
#else
#define HASH_Create_Extended HASH_Create_Extended_Int
#endif
/*************************************************************************/ /*!
@Function HASH_Create
@Description Create a self scaling hash table with a key consisting of a
single uintptr_t, and using the default hash and key
comparison functions.
@Input uInitialLen Initial and minimum length of the hash table,
where the length refers to the number of entries
in the hash table, not its size in bytes.
@Return NULL or hash table handle.
*/ /**************************************************************************/
HASH_TABLE * HASH_Create_Int(IMG_UINT32 uInitialLen);
#if defined(DEBUG)
#define HASH_Create(LEN) HASH_Create_Debug(LEN, __FILE__, __LINE__)
HASH_TABLE * HASH_Create_Debug (IMG_UINT32 uInitialLen, const char *file, const unsigned int line);
#else
#define HASH_Create HASH_Create_Int
#endif
/*************************************************************************/ /*!
@Function HASH_Delete_Extended
@Description Delete a hash table created by HASH_Create_Extended or
HASH_Create. All entries in the table should have been removed
before calling this function.
@Input pHash Hash table
@Input bWarn Set false to suppress warnings in the case of
deletion with active entries.
@Return None
*/ /**************************************************************************/
void HASH_Delete_Extended(HASH_TABLE *pHash, IMG_BOOL bWarn);
/*************************************************************************/ /*!
@Function HASH_Delete
@Description Delete a hash table created by HASH_Create_Extended or
HASH_Create. All entries in the table must have been removed
before calling this function.
@Input pHash Hash table
@Return None
*/ /**************************************************************************/
void HASH_Delete(HASH_TABLE *pHash);
/*************************************************************************/ /*!
@Function HASH_Insert_Extended
@Description Insert a key value pair into a hash table created with
HASH_Create_Extended.
@Input pHash The hash table.
@Input pKey Pointer to the key.
@Input v The value associated with the key.
@Return IMG_TRUE - success.
IMG_FALSE - failure.
*/ /**************************************************************************/
IMG_BOOL HASH_Insert_Extended(HASH_TABLE *pHash, void *pKey, uintptr_t v);
/*************************************************************************/ /*!
@Function HASH_Insert
@Description Insert a key value pair into a hash table created with
HASH_Create.
@Input pHash The hash table.
@Input k The key value.
@Input v The value associated with the key.
@Return IMG_TRUE - success.
IMG_FALSE - failure.
*/ /**************************************************************************/
IMG_BOOL HASH_Insert(HASH_TABLE *pHash, uintptr_t k, uintptr_t v);
/*************************************************************************/ /*!
@Function HASH_Remove_Extended
@Description Remove a key from a hash table created with
HASH_Create_Extended.
@Input pHash The hash table.
@Input pKey Pointer to key.
@Return 0 if the key is missing, or the value associated with the key.
*/ /**************************************************************************/
uintptr_t HASH_Remove_Extended(HASH_TABLE *pHash, void *pKey);
/*************************************************************************/ /*!
@Function HASH_Remove
@Description Remove a key value pair from a hash table created with
HASH_Create.
@Input pHash The hash table.
@Input k The key value.
@Return 0 if the key is missing, or the value associated with the key.
*/ /**************************************************************************/
uintptr_t HASH_Remove(HASH_TABLE *pHash, uintptr_t k);
/*************************************************************************/ /*!
@Function HASH_Retrieve_Extended
@Description Retrieve a value from a hash table created with
HASH_Create_Extended.
@Input pHash The hash table.
@Input pKey Pointer to key.
@Return 0 if the key is missing, or the value associated with the key.
*/ /**************************************************************************/
uintptr_t HASH_Retrieve_Extended(HASH_TABLE *pHash, void *pKey);
/*************************************************************************/ /*!
@Function HASH_Retrieve
@Description Retrieve a value from a hash table created with HASH_Create.
@Input pHash The hash table.
@Input k The key value.
@Return 0 if the key is missing, or the value associated with the key.
*/ /**************************************************************************/
uintptr_t HASH_Retrieve(HASH_TABLE *pHash, uintptr_t k);
/*************************************************************************/ /*!
@Function HASH_Iterate
@Description Iterate over every entry in the hash table.
@Input pHash Hash table to iterate.
@Input pfnCallback Callback to call with the key and data for each
. entry in the hash table
@Return Callback error if any, otherwise PVRSRV_OK
*/ /**************************************************************************/
PVRSRV_ERROR HASH_Iterate(HASH_TABLE *pHash, HASH_pfnCallback pfnCallback, void* args);
/*************************************************************************/ /*!
@Function HASH_Count
@Description Retrieve the number of entries in the hash table.
@Input pHash The hash table.
@Return The number of entries.
*/ /**************************************************************************/
IMG_UINT32 HASH_Count(HASH_TABLE *pHash);
#ifdef HASH_TRACE
/*************************************************************************/ /*!
@Function HASH_Dump
@Description Dump out some information about a hash table.
@Input pHash The hash table.
*/ /**************************************************************************/
void HASH_Dump(HASH_TABLE *pHash);
#endif
#if defined(__cplusplus)
}
#endif
#endif /* HASH_H */
/******************************************************************************
End of file (hash.h)
******************************************************************************/

View File

@@ -0,0 +1,73 @@
/*************************************************************************/ /*!
@File
@Title Reusable hash functions for hash.c.
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Implements common hash functions.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#include "hash_functions.h"
#include "img_defs.h"
/* Declaring function here to avoid dependencies that are introduced by
* including osfunc.h. */
IMG_INT32 OSStringNCompare(const IMG_CHAR *pStr1, const IMG_CHAR *pStr2,
size_t uiSize);
IMG_UINT32 HASH_Djb2_Hash(size_t uKeySize, void *pKey, IMG_UINT32 uHashTabLen)
{
IMG_CHAR *pszStr = pKey;
IMG_UINT32 ui32Hash = 5381, ui32Char;
PVR_UNREFERENCED_PARAMETER(uKeySize);
PVR_UNREFERENCED_PARAMETER(uHashTabLen);
while ((ui32Char = *pszStr++) != '\0')
{
ui32Hash = ((ui32Hash << 5) + ui32Hash) + ui32Char;
}
return ui32Hash;
}
IMG_BOOL HASH_Djb2_Compare(size_t uKeySize, void *pKey1, void *pKey2)
{
IMG_CHAR *pszKey1 = pKey1, *pszKey2 = pKey2;
return OSStringNCompare(pszKey1, pszKey2, uKeySize) == 0;
}

View File

@@ -0,0 +1,66 @@
/*************************************************************************/ /*!
@File
@Title Reusable hash functions for hash.c.
@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description Implements common hash functions.
@License Dual MIT/GPLv2
The contents of this file are subject to the MIT license as set out below.
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.
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
This License is also included in this distribution in the file called
"MIT-COPYING".
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
*/ /**************************************************************************/
#include "img_types.h"
/*************************************************************************/ /*!
@Function HASH_Djb2_Hash
@Description Hash function intended for hashing string keys. This function
implements DJB2 algorithm.
@Input uKeySize The size of the string hash key, in bytes.
@Input pKey A pointer to the string key to hash.
@Input uHashTabLen The length of the hash table.
@Return The hash value.
*/ /**************************************************************************/
IMG_UINT32 HASH_Djb2_Hash(size_t uKeySize, void *pKey, IMG_UINT32 uHashTabLen);
/*************************************************************************/ /*!
@Function HASH_Key_Comp_Default
@Description Compares string keys.
@Input uKeySize The size of the string key.
@Input pKey1 Pointer to first string hash key to compare.
@Input pKey2 Pointer to second string hash key to compare.
@Return IMG_TRUE - The keys match.
IMG_FALSE - The keys don't match.
*/ /**************************************************************************/
IMG_BOOL HASH_Djb2_Compare(size_t uKeySize, void *pKey1, void *pKey2);

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More