📄 csl_memprothwcontrol.c
字号:
/* ============================================================================
* Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005
*
* Use of this software is controlled by the terms and conditions found in the
* license agreement under which this software has been supplied.
* ===========================================================================
*/
/** @file csl_memprotHwControl.c
*
* @path $(CSLPATH)\\memprot\\src
*
* @brief File for functional layer of CSL API @a CSL_memprotHwControl()
*
* Description
* - The @a CSL_memprotHwControl() function definition & it's associated
* functions
*
* Modification 1
* - Modified on: 7/16/2004
* - Reason: created the sources
*
* @author Ruchika Kharwar.
*/
#include <csl_memprot.h>
#include <csl_memprotAux.h>
/** ===========================================================================
* @n@b CSL_memprotHwControl
*
* @b Description
* @n Control operations for the Memory protection registers.
* For a particular control operation, the pointer to the corresponding
* data type needs to be passed as argument HwControl function Call.
* All the arguments (Structure elements included) passed to the
* HwControl function are inputs. For the list of commands supported and
* argument type that can be @a void* casted & passed with a particular
* command refer to @a CSL_MemprotHwControlCmd.
*
* @b Arguments
* @verbatim
hMemprot Handle to the MEMPROT instance
cmd The command to this API indicates the action to be
taken on MEMPROT.
arg An optional argument.
@endverbatim
*
* <b> Return Value </b> CSL_Status
* @li CSL_SOK - Status info return successful.
* @li CSL_ESYS_BADHANDLE - Invalid handle
* @li CSL_ESYS_INVCMD - Invalid command
* @li CSL_ESYS_FAIL - Invalid instance number
*
* <b> Pre Condition </b>
* @n Both @a CSL_memprotInit() and @a CSL_memprotOpen() must be called
* successfully in that order before @a CSL_memprotHwControl() can be
* called. For the argument type that can be @a void* casted & passed
* with a particular command refer to @a CSL_MemprotHwControlCmd
*
* <b> Post Condition </b>
* @n None
*
* @b Modifies
* @n The hardware registers of MEMPROT.
*
* @b Example
* @verbatim
Uint16 pageAttrTable[10] = {PAGE_ATTR,PAGE_ATTR,PAGE_ATTR,PAGE_ATTR,
PAGE_ATTR,PAGE_ATTR,PAGE_ATTR,PAGE_ATTR,PAGE_ATTR,PAGE_ATTR};
Uint32 key[2] = {0x11223344,0x55667788};
CSL_MemprotObj mpL2Obj;
CSL_MemprotHandle hmpL2;
CSL_Status status;
CSL_MemprotHwSetup L2MpSetup,L2MpGetSetup;
CSL_MemprotLockStatus lockStat;
CSL_MemprotPageAttr pageAttr;
CSL_MemprotFaultStatus queryFaultStatus;
// Initializing the module
CSL_memprotInit(NULL);
// Opening the Handle for the L2
hmpL2 = CSL_memprotOpen(&mpL2Obj,CSL_MEMPROT_L2,NULL,&status);
L2MpSetup. memPageAttr = pageAttrTable;
L2MpSetup.numPages = 10;
L2MpSetup.key = key;
// Do Setup for the L2 Memory protection/
CSL_memprotHwSetup (hmpL2,&L2MpSetup);
// Query Lock Status
CSL_memprotGetHwStatus(hmpL2,CSL_MEMPROT_QUERY_LOCKSTAT,&lockStat);
// Unlock the Unit if Locked
if ((lockStat == CSL_MEMPROT_LOCKSTAT_SUNLOCK)
|| (lockStat == CSL_MEMPROT_LOCKSTAT_NSUNLOCK)) {
CSL_memprotHwControl(hmpL2,CSL_MEMPROT_CMD_UNLOCK,key);
}
@endverbatim
* ============================================================================
*/
#pragma CODE_SECTION (CSL_memprotHwControl, ".text:csl_section:memprot");
CSL_Status CSL_memprotHwControl(
/** Pointer to the object that holds reference to the
* instance of memory protection unit.
*/
CSL_MemprotHandle hMemprot,
/** The command to this API indicates the action to be taken
*/
CSL_MemprotHwControlCmd cmd,
/** An optional argument @a void* casted
*/
void *arg
)
{
CSL_Status status = CSL_SOK;
switch(cmd){
case CSL_MEMPROT_CMD_LOCK:
status = CSL_memprotLock(hMemprot,(Uint32*)(arg));
break;
case CSL_MEMPROT_CMD_UNLOCK:
status = CSL_memprotUnLock(hMemprot,(Uint32*)(arg));
break;
case CSL_MEMPROT_CMD_PAGEATTR:
CSL_memprotSetPageAttr(hMemprot,
((CSL_MemprotPageAttr*)arg)->page,
((CSL_MemprotPageAttr*)arg)->attr);
break;
default:
status = CSL_ESYS_INVCMD ;
break;
};
return status;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -