📄 dual_buffer.h
字号:
/**
* Name : dual_buffer.h
* Title : Dual Space Buffer Management.
* Author : Marcus Shawcroft
* Created : 14 May 2003
*
* Copyright : 2003 by Imagination Technologies Limited.
* All rights reserved. No part of this software, either
* material or conceptual may be copied or distributed,
* transmitted, transcribed, stored in a retrieval system
* or translated into any human or computer language in any
* form by any means, electronic, mechanical, manual or
* other-wise, or disclosed to third parties without the
* express written permission of Imagination Technologies
* Limited, Unit 8, HomePark Industrial Estate,
* King's Langley, Hertfordshire, WD4 8LZ, U.K.
*
* Description : Manages buffers mapped into two virtual memory spaces,
* cpu and device.
*
* Platform : ALL
*
*/
#ifndef _DUAL_BUFFER_H_
#define _DUAL_BUFFER_H_
#include "hostfunc.h"
#include "img_types.h"
#include "ra.h"
struct _BM_BUF_
{
IMG_CPU_VIRTADDR *CpuVAddr;
IMG_CPU_PHYADDR CpuPAddr;
IMG_DEV_VIRTADDR DevVAddr;
RA_ARENA *pArena;
void *pRef;
};
typedef struct _BM_BUF_ BM_BUF;
typedef struct _DB_STATE_ DB_STATE;
/**
* @Function DB_Initialise
*
* @Description
*
* To Initialise the dual buffer module, must be called before
* any other function within dual buffer.
*
* @Input registers - cpu virtual address for the device registers.
* @Output ppState - db_state pointer
* @Return IMG_TRUE - Success, IMG_FALSE - Failed
*/
IMG_BOOL
DB_Initialise (IMG_CPU_VIRTADDR registers,
IMG_CPU_VIRTADDR slaveports,
IMG_UINT32 ui32CoreConfig,
DB_STATE **ppState);
/**
* @Function DB_Finalise
*
* @Description
*
* To Finalise the dual buffer module. All allocated buffers must
* be free'd before calling this function.
*
* @Input pDBState - DB_STATE (from DB_Initialise())
* @Return None
*/
void
DB_Finalise (DB_STATE *pDBState);
/**
* @Function DB_Alloc
*
* @Description
*
* To allocate a buffer.
*
* @Input pDBState - dual buffer state (from DB_Initialise())
* @Input uSize - requested buffer size in bytes.
* @Input uBufferProps - property flags for the buffer.
* @Input uDevVAddrAlignment - required device virtual address
* alignment, or 0.
* @Output dev_vaddr - Receives the device virtual address of
* the allocated buffer.
* @Return cpu virtual address of the allocated buffer, or 0.
*/
void *
DB_Alloc (DB_STATE *pDBState,
IMG_SIZE_T uSize,
IMG_UINT32 uBufferProps,
IMG_UINT32 alignment,
IMG_DEV_VIRTADDR *dev_vaddr);
/**
* @Function DB_Free
*
* @Description
*
* Free a buffer previously allocated with DB_alloc().
*
* @Input pDBState - dual buffer state (from DB_Initialise())
* @Input cpu_vaddr - cpu virtual address of buffer.
* @Return None.
*/
void
DB_Free (DB_STATE *pDBState,
void *cpu_vaddr);
/**
* @Function DB_AllocBuf
*
* @Description
*
* Allocate a buffer mapped into both cpu and device virtual
* address spaces. Differs from DB_alloc () only in
* the nature of the interface.
*
* @Input pDBState - dual buffer state (from DB_Initialise())
* @Input uSize - requested buffer size in bytes.
* @Input uBufferProps - property flags for the buffer.
* @Input uDevVAddrAlignment - required device virtual address
* alignment, or 0.
* @Output ppBuf - receives a pointer to a descriptor of the
* allocated buffer.
* @Return IMG_TRUE - Success, IMG_FALSE - Failed.
*/
IMG_BOOL
DB_AllocBuf (DB_STATE *pDBState,
IMG_SIZE_T uSize,
IMG_UINT32 uBufferProps,
IMG_UINT32 uDevVAddrAlignment,
BM_BUF **ppBuf);
/**
* @Function DB_WrapBuf
*
* @Description
*
* Allocate a buffer mapped into both cpu and device virtual address
* spaces.
*
* @Input pDBState - dual buffer state (from DB_Initialise())
* @Input base - system physical base address
* @Input uSize - requested buffer size in bytes.
* @Input uBufferProps - property flags for the buffer.
* @Input uDevVAddrAlignment - required device virtual address
alignment, or 0.
* @Output ppBuf - receives a pointer to a descriptor of the
allocated buffer.
* @Return IMG_TRUE - Success, IMG_FALSE - Failed.
*/
IMG_BOOL
DB_WrapBuf (DB_STATE *pDBState,
IMG_SYS_PHYADDR base,
IMG_SIZE_T uSize,
IMG_UINT32 uBufferProps,
IMG_UINT32 uDevVAddrAlignment,
BM_BUF **ppBuf);
/**
* @Function DB_FreeBuf
*
* @Description
*
* Free a buffer previously allocated with DB_AllocBuf or
* wrapped with DB_WrapBuf().
*
* @Input pDBState - dual buffer state (from DB_Initialise())
* @Output ppBuf - buffer descriptor to free.
* @Return None.
*/
void
DB_FreeBuf (DB_STATE *pDBState,
BM_BUF **ppBuf);
/**
* @Function DB_ContiguousStatistics
*
* @Description
*
* Retrieve the contiguous buffer arena statistics.
*
* @Input pDBState - dual buffer state pointer
* @Output ppStats - receives statistics
* @Return IMG_TRUE - Success, IMG_FALSE - Failed
*/
IMG_BOOL
DB_ContiguousStatistics (DB_STATE *pDBState,
IMG_UINT32 uFlags,
RA_STATISTICS **ppStats);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -