avresource.h

来自「AMLOGIC DPF source code」· C头文件 代码 · 共 85 行

H
85
字号
/*******************************************************************
 * 
 *  Copyright C 2005 by Amlogic, Inc. All Rights Reserved.
 *
 *  Description: Declarations for AVOS periodic timer functions
 *
 *  Author: Eric Knudstrup
 *  Created: Wed Apr  6 11:47:07 2005
 *
 *******************************************************************/

#ifndef AVRESOURCE_H
#define AVRESOURCE_H


/* Resource Check Callback */
typedef INT8U (*RESOURCE_CB_t)(void*);

typedef INT32S AVResource_t;
#define AVRESOURCE_INVALID ((AVTimer_t)NULL)



/**
 * Create a new AVOS Resource.  Must be called from task context.
 * @param IN chk_period: Period to check if resource is avaible in ticks.
 * @returns Either an AVResource_t handle or AVRESOURCE_INVALID if the allocation
 *          was unsuccessful.
 */
extern AVResource_t
AVResourceCreate(INT32U chk_period);

/**
 * Release an AVOS Resource.
 *
 * @return TRUE if the delete succeeded, FALSE if not.
 */
extern int
AVResourceDelete(AVResource_t handle);

/**
 * Register a checking item into AVOS Resource.  Must be called from task context.
 * @param IN handle: Resource handle.
 * @param IN chk_callback: checking function pointer, the resource should be reserved for task that registers this item if chk_callback()!=0.
 * @param IN arg Argument tochk_callback.
 * @returns an item handle if the register sucessfully, NULL if not fail
 * Note: If one task has registered a "check item" for one AVResource, and it tries to register for the same AVResource again, 
 *           the previous "check item" will be returned and that item's chk_callback will be renewed by new param IN
 */
extern int
AVResourceRegister(AVResource_t handle, RESOURCE_CB_t chk_callback,void* arg);

/**
 * Remove a checking item from AVOS Resource.  Must be called from task context.
 * @param IN handle: Resource handle.
 * @return TRUE if the delete succeeded, FALSE if not.
 */
extern int
AVResourceUnRegister(AVResource_t handle);

/**
* Try to obtain AVOS Resource.  Must be called from task context.
* @param IN handle: Resource handle.
* @param IN timeout
* Returns    : OS_NO_ERR           The call was successful and the resource is obtained.
*                    OS_TIMEOUT   Can not obtain the resource after timeout 
*                    other: see Returns of AVSemPend()
* Note: One resource can be obtained or reserved (through  AVResourceRegister()) by other task.
            This function will be pending if the resource has been obtained by other task or reserved by the task with higher priority; 
            The resource should be reserved for the task with higher priority that has registered and it's chk_callback() return value of none zero.            
 */
extern int
AVResourceObtain(AVResource_t handle, INT8U timeout);

/**
* Release AVOS Resource.  Must be called from task context.
* @param IN handle: Resource handle.
* Returns    :  see Returns of AVSemPost()
 */

extern int
AVResourceRelease(AVResource_t handle);

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?