OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [coremark/] [core_util.c] - Diff between revs 355 and 406

Show entire file | Details | Blame | View Log

Rev 355 Rev 406
Line 34... Line 34...
        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;
Line 59... Line 60...
                                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'))) {
                while (((*valstring >= '0') && (*valstring <= '9'))
                        ee_s32 digit=*valstring-'0';
                       || ((*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 {
        } else {
                while ((*valstring >= '0') && (*valstring <= '9')) {
                while ((*valstring >= '0') && (*valstring <= '9')) {
                        ee_s32 digit=*valstring-'0';
                        ee_s32 digit = *valstring - '0';
                        retval*=10;
                        retval*=10;
                        retval+=digit;
                        retval+=digit;
                        valstring++;
                        valstring++;
                }
                }
        }
        }
Line 99... Line 102...
 
 
        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 in core_portme.h and core_portme.c ! */
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=portme_sys1();
                        retval=portme_sys1();
                        break;
                        break;
Line 141... Line 146...
*/
*/
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++) {
    {
 
                x16 = (ee_u8)((data & 1) ^ ((ee_u8)crc & 1));
                x16 = (ee_u8)((data & 1) ^ ((ee_u8)crc & 1));
                data >>= 1;
                data >>= 1;
 
 
                if (x16 == 1)
                if (x16 == 1) {
                {
 
                   crc ^= 0x4002;
                   crc ^= 0x4002;
                   carry = 1;
                   carry = 1;
                }
                } else
                else
 
                        carry = 0;
                        carry = 0;
                crc >>= 1;
                crc >>= 1;
                if (carry)
                if (carry)
                   crc |= 0x8000;
                   crc |= 0x8000;
                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++;
        }
        }
Line 198... Line 207...
        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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.