📄 smc_example.c
字号:
/* ============================================================================
* Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2006
*
* Use of this software is controlled by the terms and conditions found
* in the license agreement under which this software has been supplied.
* ============================================================================
*/
/** ============================================================================
*
* @file Smc_example.c
*
* @path $(CSLPATH)\example\c6486\smc\src
*
* @desc This example demonstrate the CSL SMC & SMCP usage.
*
* ============================================================================
* @n Target Platform: TCI6486 VDB
* ============================================================================
* @n <b> Example Description </b>
* @verbatim
This Example,
Execute code from L2 SRAM
Disable data cahe
Make some sapce as PF and others Not in SMC
Enable SMCP
Clear SMCP
Enable all events
Branch SMC (Branch back to L2 sram in next 4 packets)
-- Check interrupt is raised
Check value of all read counters
Write to SMC
Check value of all read counters(Should not change)
@endverbatim
*
* =============================================================================
*
* <b> Procedure to run the example </b>
* @verbatim
* 1. Configure the CCS setup to work with the emulator being used
* 2. Please refer CCS manual for setup configuration and loading
* proper GEL file
* 3. Launch CCS window
* 4. Open project Smc_example.pjt
* 5. Build the project and load the .out file of the project.
*
* @endverbatim
*
* =============================================================================
*/
/* =============================================================================
* Revision History
* ===============
* 18-Dec-2006 NG Created
* =============================================================================
*/
#include <stdio.h>
#include <csl_smc.h>
#include <csl_smcp.h>
#include <csl_cache.h>
#include <smc_interrupt.h>
#define WORD_COUNT 128
#pragma DATA_SECTION(smc_page16_buffer, ".smc_page16")
volatile Uint32 smc_page16_buffer[WORD_COUNT];
volatile Bool INT_OCCURED = FALSE ;
void Verify_Counter(CSL_SmcpHandle, Uint32*) ;
void buffer_init(volatile Uint32*, Uint32);
Bool code_in_smc(void) ;
/*
* =============================================================================
* @func smc_example
*
* @desc
* @n this functions configures smc and smcp
*
* @arg
* None
*
* @return
* None
* =============================================================================
*/
void smc_example (
void
)
{
int index ;
CSL_Status status;
CSL_SmcObj smcObj;
CSL_SmcHandle hSmc;
CSL_SmcpObj smcpObj;
CSL_SmcpHandle hSmcp;
Uint32 arg;
Uint32 exp_count_value[8] ;
Uint32 count_index;
/* Open smc and scmp modules */
hSmc = CSL_smcOpen(&smcObj, CSL_SMC_0, NULL, &status) ;
hSmcp = CSL_smcpOpen(&smcpObj, CSL_SMCP_0, NULL, &status) ;
/* Disable L1 Data cache. Do we have to disable L2 Cache */
CACHE_setL1dSize(CACHE_L1_0KCACHE);
buffer_init(smc_page16_buffer, WORD_COUNT);
/* Make all 32 pages prefetchable */
arg = 0xFFFFFFFF;
CSL_smcHwControl(hSmc, CSL_SMC_CMD_ENA_PREFETCH_PAGE, &arg);
/* Clear the profiler */
CSL_smcpHwControl(hSmcp, CSL_SMCP_CMD_CLR_PWS_CNT, NULL);
/* Enable the profiler for counting the statistics */
arg = 0x1;
CSL_smcpHwControl(hSmcp, CSL_SMCP_CMD_ENA_DIS_PROFILER, &arg);
/* Enable all Banks */
arg = 0xF;
CSL_smcpHwControl(hSmcp, CSL_SMCP_CMD_SET_BANK, &arg);
/* Enable all events */
arg = 0xFF;
CSL_smcpHwControl(hSmcp, CSL_SMCP_CMD_SET_MASK_WS, &arg);
/* Interrupt setup for SMCP consolidated event (eventNO = 64) */
smcIntSetup();
/* Branch to a function in SMC */
if (code_in_smc() != TRUE ) {
printf("Running code from L2 Test failed on GEM0\n");
}
/* Store the counters */
for (count_index = 0 ; count_index < 8; count_index++ ) {
exp_count_value[count_index] = hSmcp->regs->SL2PWSCNT[count_index];
}
smc_page16_buffer[0] = 0xDEADBEEF;
/* Wait delay */
for( index = 0; index < 20; index++ );
/* Check counters that shoul not change */
Verify_Counter(hSmcp, exp_count_value);
/* Check for the Interrupt */
if (INT_OCCURED) {
printf("SMC Example Passed \n");
}
else {
printf("SMC Example Failed\n");
}
}
/*
* =============================================================================
* @func Verify_Counter
*
* @desc
* @n This function is to verify the previous counter with present counter
*
* @arg
* hSmcp - smcp handle
* exp_count_value_read - array of counter
*
* @return
* None
* =============================================================================
*/
void Verify_Counter (
CSL_SmcpHandle hSmcp,
Uint32 *exp_count_value_read
)
{
Uint32 count_index;
for(count_index = 0 ; count_index < 8; count_index++ ) {
if(hSmcp->regs->SL2PWSCNT[count_index] !=
exp_count_value_read[count_index] ) {
printf("Verify_Counter : counter values are not matched\n");
}
}
}
/*
* =============================================================================
* @func buffer_init
*
* @desc
* @n This function is to intialize the buffer.
*
* @arg
* smc_buffer - smc buffer
* wordcount - number of words
*
* @return
* None
* =============================================================================
*/
void buffer_init (
volatile Uint32* smc_buffer,
Uint32 wordcount
)
{
Uint32 index = 0;
for(index =0; index < wordcount; index++){
smc_buffer[index] = 0x0000000;
}
}
/*
* =============================================================================
* @func code_in_smc
*
* @desc
* @n This function resides in smc_page17 location.
*
* @arg
* None
*
* @return
* Bool
* TRUE - Always returns
* =============================================================================
*/
#pragma CODE_SECTION(code_in_smc, ".smc_page17")
Bool code_in_smc (
void
)
{
Uint32 num1, num2, num3;
num1 = num2 = 10;
num3 = num1 + num2;
printf("%d + %d = %d\n", num1,num2,num3);
printf("This code is running from SL2\n");
return TRUE ;
}
/*
* =============================================================================
* @func main
*
* @desc
* This is the main routine, which invokes SMC example.
* =============================================================================
*/
void main (
void
)
{
printf("************** SMC and SMCP Example *******************\n");
smc_example();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -