📄 rzkdeletepartition.c
字号:
/*
* File : RZKDeletePartition
*
* Description : This file defines RZKDeletePartition API.
*
* Copyright 2004 ZiLOG Inc. ALL RIGHTS RESERVED.
*
* This file contains unpublished confidential and proprietary information
* of ZiLOG, Inc.
* NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED
* IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
* This is not a license and no use of any kind of this work is authorized
* in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's
* sole discretion
*/
#include "ZSysgen.h"
#include "ZTypes.h"
#include "ZThread.h"
#include "ZMemory.h"
#include "ZInterrupt.h"
#define pPartition ((RZK_PARTITION_t *) hPartition)
extern RZK_THREADHANDLE_t hCurrentThread;
/** extern functions */
/* Function : RZKDeletePartition
*
* Description : This function deletes memory partition specified
* by the handle.
*
* Inputs : hPartition - Specifies the handle to the partition
* that has to be deleted.
*
* Outputs : RZKERR_SUCCESS-If the partition is deleted successfully.
* RZKERR_INVALID_HANDLE-When the handle of the partition is invalid.
* RZKERR_CB_BUSY-This specifies that the partition is
* exclusively used by other thread.
*
*
* Dependencies : None.
*/
RZK_STATUS_t RZKDeletePartition
(
RZK_PARTITIONHANDLE_t hPartition
)
{
/* Local Variables */
// UCHAR cPreemptionMask ;
RZK_STATE_t uState;
/* Validate the handle passed */
#ifdef RZK_DEBUG
if ((pPartition == NULL)|| (pPartition->uState == 0) ||
(pPartition->magic_num != MAGIC_NUM_MEMORY))
return RZKERR_INVALID_HANDLE;
#endif
/* Check for created bit set*/
#ifndef RZK_PERFORMANCE
if (!(pPartition->uState & OBJECT_CREATED ))
return RZKERR_CB_BUSY;
#endif
/*Reset the created state of the memory partition control block*/
uState = RZKDisablePreemption();
pPartition->uState &= ( ~OBJECT_CREATED );
/* If no memory block has been allocated, set the uState parameter to zero and return success */
if(pPartition->uMemoryBlocksLeft == pPartition->uMemoryBlocks)
{
pPartition->uState = 0;
RZKRestorePreemption(uState);
return RZKERR_SUCCESS;
}
/*If any of the memory control blocks are in use by any thread return error */
else
{
pPartition->uState = OBJECT_BUSY | OBJECT_CREATED;
RZKRestorePreemption(uState);
return RZKERR_OBJECT_IN_USE;
} /* End of delete memory partition*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -