TX51 pre-release
authorlothar <lothar>
Thu, 14 Jan 2010 17:41:17 +0000 (17:41 +0000)
committerlothar <lothar>
Thu, 14 Jan 2010 17:41:17 +0000 (17:41 +0000)
packages/services/diagnosis/v2_0/src/memory/ram_rw.c

index b27bd16..ae243ff 100644 (file)
@@ -36,32 +36,47 @@ static void raw_rw_case1(void)
        while( (round++) < loops1) {
                if (_rb_break(0))
                        return;
-               if(burst) {
-                       current_write =(unsigned int *)start;
-                       memset(current_write, (pattern1&0xFF000000)>>24, length);
+               if (burst) {
+                       current_write = (unsigned int *)start;
+                       memset(current_write, (pattern1 & 0xFF000000) >> 24, length);
                } else {
-                       for(current_write=(unsigned int *)start; current_write<(unsigned int *)(start + length); current_write += 2) {
-                               *current_write = ((unsigned int)current_write & 0x0000FFFF)|(0xFFFF0000 & pattern1);
+                       for (current_write = (unsigned int *)start;
+                               current_write < (unsigned int *)(start + length);
+                               current_write += 2) {
+                               *current_write = ((unsigned int)current_write & 0x0000FFFF) |
+                                       (0xFFFF0000 & pattern1);
                        }
-                       for(current_write=(unsigned int *)start + 1; current_write<(unsigned int *)(start + length); current_write += 2) {
-                               *current_write = ((unsigned int)current_write & 0x0000FFFF)|(0xFFFF0000 & pattern2);
+                       for (current_write = (unsigned int *)start + 1;
+                               current_write < (unsigned int *)(start + length);
+                                current_write += 2) {
+                               *current_write = ((unsigned int)current_write & 0x0000FFFF) |
+                                       (0xFFFF0000 & pattern2);
                        }
                }
-               for(current_read=(unsigned int *)start; current_read<(unsigned int *)(start + length); current_read ++) {
-                       if(burst) {
-                               if((*current_read) != pattern2) {
-                                       diag_printf("\tround %d::[0x%08x]=0x%08x:0x%08x\n", round, current_read, pattern2, *current_read);
+               for (current_read = (unsigned int *)start;
+                        current_read<(unsigned int *)(start + length);
+                        current_read ++) {
+                       if (burst) {
+                               if ((*current_read) != pattern2) {
+                                       diag_printf("\tround %d::[%p]=0x%08x:0x%08x\n", round,
+                                                               current_read, pattern2, *current_read);
                                        goto fail;
                                }
                        } else {
                                if((current_read - (unsigned int *)start) & 1) {
                                        if(((*current_read)&0xFFFF0000) != (pattern2&0xFFFF0000)) {
-                                               diag_printf("\tround %d::[0x%08x]=0x%08x:0x%08x\n", round, current_read, (pattern2&0xFFFF0000)|((unsigned int)current_read)&0xFFFF, *current_read);
+                                               diag_printf("\tround %d::[%p]=0x%08x:0x%08x\n", round,
+                                                                       current_read, (pattern2 & 0xFFFF0000) |
+                                                                       (((unsigned int)current_read) & 0xFFFF),
+                                                                       *current_read);
                                                goto fail;
                                        }
                                } else {
                                        if(((*current_read)&0xFFFF0000) != (pattern1&0xFFFF0000)) {
-                                               diag_printf("\tround %d::[0x%08x]=0x%08x:0x%08x\n", round, current_read, (pattern1&0xFFFF0000)|((unsigned int)current_read)&0xFFFF, *current_read);
+                                               diag_printf("\tround %d::[%p]=0x%08x:0x%08x\n", round,
+                                                                       current_read, (pattern1 & 0xFFFF0000) |
+                                                                       (((unsigned int)current_read) & 0xFFFF),
+                                                                       *current_read);
                                                goto fail;
                                        }
                                }
@@ -83,44 +98,44 @@ static void ram_rw_test(int argc, char * argv[])
        memset(opts_map, 0, sizeof(int)*6);
 
        init_opts(&opts[0], 'c', true, OPTION_ARG_TYPE_NUM,
-                (void *)&loops1, (bool *)&opts_map[0], "the rounds of test");
+                &loops1, &opts_map[0], "the rounds of test");
        init_opts(&opts[1], 'b', true, OPTION_ARG_TYPE_NUM,
-                (void *)&start, (bool *)&opts_map[1], "accessing start address");
+                &start, &opts_map[1], "accessing start address");
        init_opts(&opts[2], 'l', true, OPTION_ARG_TYPE_NUM,
-                (void *)&length, (bool *)&opts_map[2], "accessing size(bytes)");
+                &length, &opts_map[2], "accessing size(bytes)");
        init_opts(&opts[3], 'p', true, OPTION_ARG_TYPE_NUM,
-                (void *)&pattern1, (bool *)&opts_map[3], "High 16bit is valid");
+                &pattern1, &opts_map[3], "High 16bit is valid");
        init_opts(&opts[4], 'm', true, OPTION_ARG_TYPE_NUM,
-                (void *)&mode, (bool *)&opts_map[4], "Test case number");
+                &mode, &opts_map[4], "Test case number");
        init_opts(&opts[5], 's', false, OPTION_ARG_TYPE_FLG,
-                (void *)&burst, (bool *)0, "enable bust mode(based on memset)");
+                &burst, NULL, "enable bust mode(based on memset)");
 
        if (!scan_opts(argc, argv, 2, opts, 6, 0, 0, 0)) {
                diagnosis_usage("invalid arguments");
                return;
        }
 
-       if(!opts_map[0]) {
+       if (!opts_map[0]) {
                loops1 = 32;
        }
 
-       if(!opts_map[1]) {
+       if (!opts_map[1]) {
                start = 0x80000;
        }
 
-       if(!opts_map[2]) {
+       if (!opts_map[2]) {
                length = 8192;
        }
 
-       if(!opts_map[3]) {
+       if (!opts_map[3]) {
                pattern1 = 0x55550000;
        }
 
-       if(!opts_map[4]) {
+       if (!opts_map[4]) {
                mode = DIAGNOSIS_MEM_RAM_RD;
        }
 
-       if(burst) {
+       if (burst) {
                pattern2 = (pattern1&0xFF000000);
                pattern2 |= pattern2>>8;
                pattern2 |= pattern2>>16;
@@ -162,7 +177,6 @@ static void memcpybm(int argc, char * argv[])
 {
        int opts_map[OPT_SIZE];
        struct option_info opts[OPT_SIZE];
-       int mode;
        int size = START_SIZE / SIZE_1K;
        int end_size = END_SIZE / SIZE_1K;
        int salign = ALIGN;
@@ -174,15 +188,15 @@ static void memcpybm(int argc, char * argv[])
        memset(opts_map, 0, sizeof(int)*OPT_SIZE);
 
        init_opts(&opts[0], 'c', true, OPTION_ARG_TYPE_NUM,
-                (void *)&loops, (bool *)&opts_map[0], "the rounds of test in thousands");
+                &loops, &opts_map[0], "the rounds of test in thousands");
        init_opts(&opts[1], 's', true, OPTION_ARG_TYPE_NUM,
-                (void *)&size, (bool *)&opts_map[1], "start size in KB");
+                &size, &opts_map[1], "start size in KB");
        init_opts(&opts[2], 'e', true, OPTION_ARG_TYPE_NUM,
-                (void *)&end_size, (bool *)&opts_map[2], "end size in KB");
+                &end_size, &opts_map[2], "end size in KB");
        init_opts(&opts[3], 'a', true, OPTION_ARG_TYPE_NUM,
-                (void *)&salign, (bool *)&opts_map[3], "source align in byte");
+                &salign, &opts_map[3], "source align in byte");
        init_opts(&opts[4], 'b', true, OPTION_ARG_TYPE_NUM,
-                (void *)&dalign, (bool *)&opts_map[4], "destination align in byte");
+                &dalign, &opts_map[4], "destination align in byte");
 
        if (!scan_opts(argc, argv, 2, opts, OPT_SIZE, 0, 0, 0)) {
                diagnosis_usage("invalid arguments");
@@ -239,9 +253,9 @@ static void memcpybm(int argc, char * argv[])
                elapsed_time = (clock() - start_time);
 
                sz = size *loops * 2;
-               printf("   %d", sz*CLOCKS_PER_SEC/elapsed_time/SIZE_1M);
-               printf("\t elapsed=%d", elapsed_time);
-               printf("\tsize=%d, loops=%d, sz=%d", size, loops, sz);
+               printf("   %llu", sz * CLOCKS_PER_SEC / elapsed_time / SIZE_1M);
+               printf("\t elapsed=%u", elapsed_time);
+               printf("\tsize=%d, loops=%d, sz=%llu", size, loops, sz);
                printf("\n");
 
 /*