Line 18... |
Line 18... |
|
|
#include "coremark.h"
|
#include "coremark.h"
|
/* Function: get_seed
|
/* Function: get_seed
|
Get a values that cannot be determined at compile time.
|
Get a values that cannot be determined at compile time.
|
|
|
Since different embedded systems and compilers are used, 3 different methods are provided:
|
Since different embedded systems and compilers are used, 3 different
|
1 - Using a volatile variable. This method is only valid if the compiler is forced to generate code that
|
methods are provided: 1 - Using a volatile variable. This method is only
|
reads the value of a volatile variable from memory at run time.
|
valid if the compiler is forced to generate code that reads the value of a
|
Please note, if using this method, you would need to modify core_portme.c to generate training profile.
|
volatile variable from memory at run time. Please note, if using this method,
|
2 - Command line arguments. This is the preferred method if command line arguments are supported.
|
you would need to modify core_portme.c to generate training profile. 2 -
|
3 - System function. If none of the first 2 methods is available on the platform,
|
Command line arguments. This is the preferred method if command line
|
a system function which is not a stub can be used.
|
arguments are supported. 3 - System function. If none of the first 2 methods
|
|
is available on the platform, a system function which is not a stub can be
|
|
used.
|
|
|
e.g. read the value on GPIO pins connected to switches, or invoke special simulator functions.
|
e.g. read the value on GPIO pins connected to switches, or invoke
|
|
special simulator functions.
|
*/
|
*/
|
#if (SEED_METHOD==SEED_VOLATILE)
|
#if (SEED_METHOD==SEED_VOLATILE)
|
extern volatile ee_s32 seed1_volatile;
|
extern volatile ee_s32 seed1_volatile;
|
extern volatile ee_s32 seed2_volatile;
|
extern volatile ee_s32 seed2_volatile;
|
extern volatile ee_s32 seed3_volatile;
|
extern volatile ee_s32 seed3_volatile;
|
extern volatile ee_s32 seed4_volatile;
|
extern volatile ee_s32 seed4_volatile;
|
extern volatile ee_s32 seed5_volatile;
|
extern volatile ee_s32 seed5_volatile;
|
ee_s32 get_seed_32(int i) {
|
ee_s32
|
|
get_seed_32(int i)
|
|
{
|
ee_s32 retval;
|
ee_s32 retval;
|
switch (i) {
|
switch (i)
|
|
{
|
case 1:
|
case 1:
|
retval=seed1_volatile;
|
retval=seed1_volatile;
|
break;
|
break;
|
case 2:
|
case 2:
|
retval=seed2_volatile;
|
retval=seed2_volatile;
|
Line 59... |
Line 65... |
break;
|
break;
|
}
|
}
|
return retval;
|
return retval;
|
}
|
}
|
#elif (SEED_METHOD==SEED_ARG)
|
#elif (SEED_METHOD==SEED_ARG)
|
ee_s32 parseval(char *valstring) {
|
ee_s32
|
|
parseval(char *valstring)
|
|
{
|
ee_s32 retval=0;
|
ee_s32 retval=0;
|
ee_s32 neg=1;
|
ee_s32 neg=1;
|
int hexmode=0;
|
int hexmode=0;
|
if (*valstring == '-') {
|
if (*valstring == '-')
|
neg=-1;
|
{
|
|
neg = -1;
|
valstring++;
|
valstring++;
|
}
|
}
|
if ((valstring[0] == '0') && (valstring[1] == 'x')) {
|
if ((valstring[0] == '0') && (valstring[1] == 'x'))
|
|
{
|
hexmode=1;
|
hexmode=1;
|
valstring+=2;
|
valstring+=2;
|
}
|
}
|
/* first look for digits */
|
/* first look for digits */
|
if (hexmode) {
|
if (hexmode)
|
while (((*valstring >= '0') && (*valstring <= '9')) || ((*valstring >= 'a') && (*valstring <= 'f'))) {
|
{
|
ee_s32 digit=*valstring-'0';
|
while (((*valstring >= '0') && (*valstring <= '9'))
|
|
|| ((*valstring >= 'a') && (*valstring <= 'f')))
|
|
{
|
|
ee_s32 digit = *valstring - '0';
|
if (digit>9)
|
if (digit>9)
|
digit=10+*valstring-'a';
|
digit = 10 + *valstring - 'a';
|
retval*=16;
|
retval*=16;
|
retval+=digit;
|
retval+=digit;
|
valstring++;
|
valstring++;
|
}
|
}
|
} else {
|
}
|
while ((*valstring >= '0') && (*valstring <= '9')) {
|
else
|
ee_s32 digit=*valstring-'0';
|
{
|
|
while ((*valstring >= '0') && (*valstring <= '9'))
|
|
{
|
|
ee_s32 digit = *valstring - '0';
|
retval*=10;
|
retval*=10;
|
retval+=digit;
|
retval+=digit;
|
valstring++;
|
valstring++;
|
}
|
}
|
}
|
}
|
Line 99... |
Line 115... |
|
|
retval*=neg;
|
retval*=neg;
|
return retval;
|
return retval;
|
}
|
}
|
|
|
ee_s32 get_seed_args(int i, int argc, char *argv[]) {
|
ee_s32
|
|
get_seed_args(int i, int argc, char *argv[])
|
|
{
|
if (argc>i)
|
if (argc>i)
|
return parseval(argv[i]);
|
return parseval(argv[i]);
|
return 0;
|
return 0;
|
}
|
}
|
|
|
#elif (SEED_METHOD==SEED_FUNC)
|
#elif (SEED_METHOD==SEED_FUNC)
|
/* If using OS based function, you must define and implement the functions below in core_portme.h and core_portme.c ! */
|
/* If using OS based function, you must define and implement the functions below
|
ee_s32 get_seed_32(int i) {
|
* in core_portme.h and core_portme.c ! */
|
|
ee_s32
|
|
get_seed_32(int i)
|
|
{
|
ee_s32 retval;
|
ee_s32 retval;
|
switch (i) {
|
switch (i)
|
|
{
|
case 1:
|
case 1:
|
retval=portme_sys1();
|
retval=portme_sys1();
|
break;
|
break;
|
case 2:
|
case 2:
|
retval=portme_sys2();
|
retval=portme_sys2();
|
Line 137... |
Line 159... |
|
|
/* Function: crc*
|
/* Function: crc*
|
Service functions to calculate 16b CRC code.
|
Service functions to calculate 16b CRC code.
|
|
|
*/
|
*/
|
ee_u16 crcu8(ee_u8 data, ee_u16 crc )
|
ee_u16
|
|
crcu8(ee_u8 data, ee_u16 crc)
|
{
|
{
|
ee_u8 i=0,x16=0,carry=0;
|
ee_u8 i=0,x16=0,carry=0;
|
|
|
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
{
|
{
|
Line 161... |
Line 184... |
else
|
else
|
crc &= 0x7fff;
|
crc &= 0x7fff;
|
}
|
}
|
return crc;
|
return crc;
|
}
|
}
|
ee_u16 crcu16(ee_u16 newval, ee_u16 crc) {
|
ee_u16
|
|
crcu16(ee_u16 newval, ee_u16 crc)
|
|
{
|
crc=crcu8( (ee_u8) (newval) ,crc);
|
crc=crcu8( (ee_u8) (newval) ,crc);
|
crc=crcu8( (ee_u8) ((newval)>>8) ,crc);
|
crc=crcu8( (ee_u8) ((newval)>>8) ,crc);
|
return crc;
|
return crc;
|
}
|
}
|
ee_u16 crcu32(ee_u32 newval, ee_u16 crc) {
|
ee_u16
|
|
crcu32(ee_u32 newval, ee_u16 crc)
|
|
{
|
crc=crc16((ee_s16) newval ,crc);
|
crc=crc16((ee_s16) newval ,crc);
|
crc=crc16((ee_s16) (newval>>16) ,crc);
|
crc=crc16((ee_s16) (newval>>16) ,crc);
|
return crc;
|
return crc;
|
}
|
}
|
ee_u16 crc16(ee_s16 newval, ee_u16 crc) {
|
ee_u16
|
|
crc16(ee_s16 newval, ee_u16 crc)
|
|
{
|
return crcu16((ee_u16)newval, crc);
|
return crcu16((ee_u16)newval, crc);
|
}
|
}
|
|
|
ee_u8 check_data_types() {
|
ee_u8
|
|
check_data_types()
|
|
{
|
ee_u8 retval=0;
|
ee_u8 retval=0;
|
if (sizeof(ee_u8) != 1) {
|
if (sizeof(ee_u8) != 1)
|
|
{
|
ee_printf("ERROR: ee_u8 is not an 8b datatype!\n");
|
ee_printf("ERROR: ee_u8 is not an 8b datatype!\n");
|
retval++;
|
retval++;
|
}
|
}
|
if (sizeof(ee_u16) != 2) {
|
if (sizeof(ee_u16) != 2)
|
|
{
|
ee_printf("ERROR: ee_u16 is not a 16b datatype!\n");
|
ee_printf("ERROR: ee_u16 is not a 16b datatype!\n");
|
retval++;
|
retval++;
|
}
|
}
|
if (sizeof(ee_s16) != 2) {
|
if (sizeof(ee_s16) != 2)
|
|
{
|
ee_printf("ERROR: ee_s16 is not a 16b datatype!\n");
|
ee_printf("ERROR: ee_s16 is not a 16b datatype!\n");
|
retval++;
|
retval++;
|
}
|
}
|
if (sizeof(ee_s32) != 4) {
|
if (sizeof(ee_s32) != 4)
|
|
{
|
ee_printf("ERROR: ee_s32 is not a 32b datatype!\n");
|
ee_printf("ERROR: ee_s32 is not a 32b datatype!\n");
|
retval++;
|
retval++;
|
}
|
}
|
if (sizeof(ee_u32) != 4) {
|
if (sizeof(ee_u32) != 4)
|
|
{
|
ee_printf("ERROR: ee_u32 is not a 32b datatype!\n");
|
ee_printf("ERROR: ee_u32 is not a 32b datatype!\n");
|
retval++;
|
retval++;
|
}
|
}
|
if (sizeof(ee_ptr_int) != sizeof(int *)) {
|
if (sizeof(ee_ptr_int) != sizeof(int *))
|
ee_printf("ERROR: ee_ptr_int is not a datatype that holds an int pointer!\n");
|
{
|
|
ee_printf(
|
|
"ERROR: ee_ptr_int is not a datatype that holds an int pointer!\n");
|
retval++;
|
retval++;
|
}
|
}
|
if (retval>0) {
|
if (retval > 0)
|
|
{
|
ee_printf("ERROR: Please modify the datatypes in core_portme.h!\n");
|
ee_printf("ERROR: Please modify the datatypes in core_portme.h!\n");
|
}
|
}
|
return retval;
|
return retval;
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|