📄 result.c
字号:
//===============================================================================
// TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
//
// Property of Texas Instruments
// For Unrestricted Internal Use Only
// Unauthorized reproduction and/or distribution is strictly prohibited.
// This product is protected under copyright law and trade secret law
// as an unpublished work.
//
// Created 1999, (C) Copyright 1999 Texas Instruments. All rights reserved.
//
// Filename : Result.c
//
// Description : Main file for the Result Area,
// which contains all the test status
// into a table of 128 values in 16 bits size
// 1) Global i.e. Final result Item 0
// 2) Intermediary tests Items 1..99
// 3) Debug tests Items 100 .. 126
// 4) Stop Marker Set to 0xFFFF Item 127
// to make VHDL bench test stopping
// Project : TI925MM
// Author : Francois Reygagne freygagn@tif.ti.com
//===============================================================================
#include "test.h"
#include "global_types.h"
#include "result.h"
#include "intvecs.h"
#include "result.h"
#include "reset.h"
UWORD16 result [ RESULT_SIZE+2 ] ; // To accomodate with LED we reserve 2 more values
static UWORD16* start_location = NULL;
static UWORD16* start_result = (UWORD16*)&result;
static UWORD16* global_value= (UWORD16*)((&result) +1);
/* Points the first elementary result */
/* Allows to reserve a number of result items */
/* in the range 1 .. (IndexFirstValue - 1) */
static UWORD16* ptcurrent_value = NULL;
static UWORD16* ptresult_current = (UWORD16*)&result;
/*
----------------------------------------------------------
- RES_SetLocation -
----------------------------------------------------------
*/
void RES_SetLocation(const UWORD32 start_address)
{
start_location = (UWORD16*)(start_address);
start_result = (UWORD16*)&result;
ptcurrent_value = (UWORD16*)(start_address);
ptresult_current = start_result;
global_value= start_result+1;
}
/*
-----------------------------------------------------------------
- RES_SetIndex -
-----------------------------------------------------------------
*/
void RES_SetIndex(const UWORD8 FirstPosition)
{
ptcurrent_value = start_location + FirstPosition ;
}
/*
----------------------------------------------------------------
- RES_IndexedSet -
----------------------------------------------------------------
*/
void RES_IndexedSet(const UWORD8 index, const UWORD16 status)
{
*(start_location+index) = status;
*(start_result+index) = status;
}
/*
----------------------------------------------
- RES_Set Status -
----------------------------------------------
*/
void RES_Set(const UWORD16 status)
{
ptcurrent_value++;
*(ptcurrent_value) = status;
ptresult_current++;
*(ptresult_current)= status;
}
//----------------------------------------------------------
// NAME : RES_EraseResult
// DESCRIPTION : Erase all the spy result memory (write 0xFFFF).
// PARAMETERS : None
// RETURN VALUE: None
//
// LIMITATIONS : Must be used before to start a test
// ---------------------------------------------------------
void RES_EraseResult(void)
{
UWORD16* value;
for(value = start_result ; value < (start_result + RESULT_SIZE) ; value++)
(*value) = RES_THE_END;
ptresult_current = start_result;
} // End RES_EraseResult
/*
------------------------------------------------------
- RES_GetCurrentIndex -
------------------------------------------------------
*/
UWORD8 RES_GetCurrentIndex(void)
{
// when you substract 2 pointers, it returns the number of elements between the 2 address
// and not the offset between the 2 adress
return ((UWORD8)(ptcurrent_value - start_location));
}
/*
------------------------------------------------------
- RES_Stop Vhdl -
------------------------------------------------------
*/
void RES_StopVhdl(void)
{
*(start_location+LAST_ITEM_POS) = RES_THE_END;
while(1)
{ };
}
/*
------------------------------------------------------
- RES_Break -
------------------------------------------------------
*/
void RES_Break(void)
{
*(start_location+LAST_ITEM_POS) = RES_THE_END;
}
/*
--------------------------------------------------------------------
- RES_GetFinal -
--------------------------------------------------------------------
*/
UWORD16 RES_GetFinal(void)
{
UWORD16* value;
BOOL badvalue = False;
value = start_result + 1;
while ((value <= ptresult_current) && (badvalue == False))
{
if ( (*value) != RES_OK )
{
(*start_location) = *value;
badvalue = True;
}
else
{
value++;
}
}
if (badvalue == False)
(*start_location) = RES_OK;
return (*start_location);
} /* End RES_GetFinal ---------------------------------------------*/
//----------------------------------------------------------
// NAME : RES_GetFinal2
// DESCRIPTION : Scan the result array and set the first word
// to RES_NOT_TRIED, RES_BAD, or RES_OK
//
// PARAMETERS : None
// RETURN VALUE: global status of the test
//
// LIMITATIONS : Must be used at the end of test
// ----------------------------------------------------------
/*
Function commented to be sure everything still compile before deleting it.
==========================================================================
UWORD16 RES_GetFinal2(void)
{
UWORD16* value;
//(*start_location) = RES_NOT_TRIED;
for (value = start_result + 1; value <= ptresult_current; value++)
{
if ( (*value) == DATA_STORE)
{
value++;
}
else
if ( (*value) == START_ARRAY_DATA )
{
while(((*value) != END_ARRAY_DATA) AND (value <= ptresult_current))
{
value++;
}
}
else
if ( (*value) != RESULT_SEPARATOR )
{
if ( (*value) != TEST_OK )
{
(*start_location) = RES_BAD;
return RES_BAD;
}
}//endif
}// end for
(*start_location) = RES_OK;
return RES_OK;
} // End RES_GetFinal
*/
//----------------------------------------------------------
// NAME : RES_GetFinal2
// DESCRIPTION : Allow to have some more code as good ones.
// This function is especially done for the test
// of reset values or the test register access
//
// This function allow to have the codes from MIN_ARRAY_OK
// to MIN_ARRAY_OK not to be error codes. These 2 constants
// are defined in result.h.
//
// PARAMETERS : None
// RETURN VALUE: global status of the test
//
// LIMITATIONS : Must be used at the end of test
// ----------------------------------------------------------
UWORD16 RES_GetFinal2(void)
{
UWORD16* value;
//(*start_location) = RES_NOT_TRIED;
for (value = start_result + 1; value <= ptresult_current; value++)
{
if ( (*value) == DATA_STORE)
value++;
if ( (*global_value) == DATAEXPECTED_DATAREAD)
global_value+=2;
else
if ( (*value) == START_ARRAY_DATA )
{
while(((*value) != END_ARRAY_DATA) AND (value <= ptresult_current))
value++;
}
else
if ( (*value) != RESULT_SEPARATOR &&
(*value) != TEST_OK &&
(*value) != TEST_RESET_VALUE_SEPARATOR &&
(*value) != TEST_MODULE_SEPARATOR &&
(*value) != GLOBAL_TEST_SEPARATOR &&
((*value)<MIN_ARRAY_OK ||
(*value)>MAX_ARRAY_OK))
{
(*start_location) = RES_BAD;
(*start_result) = RES_BAD;
return RES_BAD;
}//endif
}// end for
(*start_location) = RES_OK;
(*start_result) = RES_OK;
return RES_OK;
} // End RES_GetFinal
/*
--------------------------------------------------------------------
- RES_GetIntermediate body -
--------------------------------------------------------------------
*/
UWORD16 RES_GetIntermediate(const UWORD8 First,
const UWORD8 Last)
{
UWORD16* value;
//(*start_location) = RES_NOT_TRIED;
for (value = start_result + First; value <= start_result + Last; value++)
{
if ( (*value) == RES_BAD )
{
(*start_location) = RES_BAD;
return RES_BAD;
}
else if ( (*value) == RES_NOT_TRIED )
{
(*start_location) = RES_NOT_TRIED;
return RES_NOT_TRIED;
}
else (*start_location) = RES_OK;
}/*end for -------------------------------------------------*/
return RES_OK;
} /* End RES_GetIntermediate --------------------------------*/
/*
--------------------------------------------------------------------
- RES_GetCurrentRes body -
--------------------------------------------------------------------
*/
UWORD16 RES_GetCurrentRes(void)
{
UWORD16* value=start_result+1;
for(value=start_result+1; value <= ptresult_current; value++)
{
if ( (*value) == DATA_STORE)
value++;
else if ( (*value) == START_ARRAY_DATA )
while( (*value) != END_ARRAY_DATA && value <= ptresult_current)
value++;
else if ( (*value) != RESULT_SEPARATOR &&
(*value) != TEST_OK &&
((*value)<MIN_ARRAY_OK ||
(*value)>MAX_ARRAY_OK))
return CURRENT_RES_NOT_OK;
}// end while
return TEST_OK;
}
/*
--------------------------------------------------------------------
- RES_GetCurrentRes2 body -
--------------------------------------------------------------------
*/
UWORD16 RES_GetCurrentRes2(UWORD16 TestPassedSuccessfuly)
{
if(TestPassedSuccessfuly==RESULT_SEPARATOR)
{
global_value=start_result+1;
return RESULT_SEPARATOR;
}
// If no codes were added since last time, current test is supposed
// to be be OK.
if(global_value>ptresult_current)
return TestPassedSuccessfuly;
while(global_value <= ptresult_current)
{
if ( (*global_value) == DATA_STORE)
global_value++;
if ( (*global_value) == DATAEXPECTED_DATAREAD)
global_value+=2;
else if ( (*global_value) == START_ARRAY_DATA )
while( (*global_value) != END_ARRAY_DATA && global_value <= ptresult_current)
global_value++;
else if ( (*global_value) != RESULT_SEPARATOR &&
(*global_value) != TEST_OK &&
(*global_value) != TEST_RESET_VALUE_SEPARATOR &&
(*global_value) != TEST_MODULE_SEPARATOR &&
(*global_value) != GLOBAL_TEST_SEPARATOR &&
(*global_value) != CURRENT_RES_NOT_OK &&
((*global_value)<=MIN_ARRAY_OK ||
(*global_value)>=MAX_ARRAY_OK))
{
global_value=ptresult_current+1;
return CURRENT_RES_NOT_OK;
}
global_value++;
}// end while
return TestPassedSuccessfuly;
}
// END OF FILE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -