]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo_bsp/ps7_cortexa9_0/libsrc/standalone_v4_1/src/xil_testmem.c
Remove obsolete MPU demos.
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo_bsp / ps7_cortexa9_0 / libsrc / standalone_v4_1 / src / xil_testmem.c
1 /******************************************************************************
2 *
3 * Copyright (C) 2009 - 2014 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34 *
35 * @file xil_testmem.c
36 *
37 * Contains the memory test utility functions.
38 *
39 * <pre>
40 * MODIFICATION HISTORY:
41 *
42 * Ver    Who    Date    Changes
43 * ----- ---- -------- -----------------------------------------------
44 * 1.00a hbm  08/25/09 First release
45 * </pre>
46 *
47 *****************************************************************************/
48
49 /***************************** Include Files ********************************/
50 #include "xil_testmem.h"
51 #include "xil_io.h"
52 #include "xil_assert.h"
53
54 /************************** Constant Definitions ****************************/
55 /************************** Function Prototypes *****************************/
56
57 static u32 RotateLeft(u32 Input, u8 Width);
58
59 /* define ROTATE_RIGHT to give access to this functionality */
60 /* #define ROTATE_RIGHT */
61 #ifdef ROTATE_RIGHT
62 static u32 RotateRight(u32 Input, u8 Width);
63 #endif /* ROTATE_RIGHT */
64
65
66 /*****************************************************************************/
67 /**
68 *
69 * Perform a destructive 32-bit wide memory test.
70 *
71 * @param    Addr is a pointer to the region of memory to be tested.
72 * @param    Words is the length of the block.
73 * @param    Pattern is the constant used for the constant pattern test, if 0,
74 *           0xDEADBEEF is used.
75 * @param    Subtest is the test selected. See xil_testmem.h for possible
76 *           values.
77 *
78 * @return
79 *
80 * - 0 is returned for a pass
81 * - -1 is returned for a failure
82 *
83 * @note
84 *
85 * Used for spaces where the address range of the region is smaller than
86 * the data width. If the memory range is greater than 2 ** Width,
87 * the patterns used in XIL_TESTMEM_WALKONES and XIL_TESTMEM_WALKZEROS will
88 * repeat on a boundry of a power of two making it more difficult to detect
89 * addressing errors. The XIL_TESTMEM_INCREMENT and XIL_TESTMEM_INVERSEADDR
90 * tests suffer the same problem. Ideally, if large blocks of memory are to be
91 * tested, break them up into smaller regions of memory to allow the test
92 * patterns used not to repeat over the region tested.
93 *
94 *****************************************************************************/
95 int Xil_TestMem32(u32 *Addr, u32 Words, u32 Pattern, u8 Subtest)
96 {
97         u32 I;
98         u32 J;
99         u32 Val;
100         u32 FirtVal;
101         u32 Word;
102
103         Xil_AssertNonvoid(Words != 0);
104         Xil_AssertNonvoid(Subtest <= XIL_TESTMEM_MAXTEST);
105
106         /*
107          * variable initialization
108          */
109         Val = XIL_TESTMEM_INIT_VALUE;
110         FirtVal = XIL_TESTMEM_INIT_VALUE;
111
112         /*
113          * Select the proper Subtest
114          */
115         switch (Subtest) {
116
117         case XIL_TESTMEM_ALLMEMTESTS:
118
119                 /* this case executes all of the Subtests */
120
121                 /* fall through case statement */
122
123         case XIL_TESTMEM_INCREMENT:
124
125                 /*
126                  * Fill the memory with incrementing
127                  * values starting from 'FirtVal'
128                  */
129                 for (I = 0L; I < Words; I++) {
130                         Addr[I] = Val;
131                         Val++;
132                 }
133
134                 /*
135                  * Restore the reference 'Val' to the
136                  * initial value
137                  */
138                 Val = FirtVal;
139
140                 /*
141                  * Check every word within the words
142                  * of tested memory and compare it
143                  * with the incrementing reference
144                  * Val
145                  */
146
147                 for (I = 0L; I < Words; I++) {
148                         Word = Addr[I];
149
150                         if (Word != Val) {
151                                 return -1;
152                         }
153
154                         Val++;
155                 }
156
157
158                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
159                         return 0;
160                 }
161
162
163                 /* end of case 1 */
164
165                 /* fall through case statement */
166
167         case XIL_TESTMEM_WALKONES:
168                 /*
169                  * set up to cycle through all possible initial
170                  * test Patterns for walking ones test
171                  */
172
173                 for (J = 0L; J < 32; J++) {
174                         /*
175                          * Generate an initial value for walking ones test
176                          * to test for bad data bits
177                          */
178
179                         Val = 1 << J;
180
181                         /*
182                          * START walking ones test
183                          * Write a one to each data bit indifferent locations
184                          */
185
186                         for (I = 0L; I < 32; I++) {
187                                 /* write memory location */
188                                 Addr[I] = Val;
189                                 Val = (u32) RotateLeft(Val, 32);
190                         }
191
192                         /*
193                          * Restore the reference 'val' to the
194                          * initial value
195                          */
196                         Val = 1 << J;
197
198                         /* Read the values from each location that was
199                          * written */
200                         for (I = 0L; I < 32; I++) {
201                                 /* read memory location */
202
203                                 Word = Addr[I];
204
205                                 if (Word != Val) {
206                                         return -1;
207                                 }
208
209                                 Val = (u32)RotateLeft(Val, 32);
210                         }
211
212                 }
213
214                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
215                         return 0;
216                 }
217
218                 /* end of case 2 */
219                 /* fall through case statement */
220
221         case XIL_TESTMEM_WALKZEROS:
222                 /*
223                  * set up to cycle through all possible
224                  * initial test Patterns for walking zeros test
225                  */
226
227                 for (J = 0L; J < 32; J++) {
228
229                         /*
230                          * Generate an initial value for walking ones test
231                          * to test for bad data bits
232                          */
233
234                         Val = ~(1 << J);
235
236                         /*
237                          * START walking zeros test
238                          * Write a one to each data bit indifferent locations
239                          */
240
241                         for (I = 0L; I < 32; I++) {
242                                 /* write memory location */
243                                 Addr[I] = Val;
244                                 Val = ~((u32)RotateLeft(~Val, 32));
245                         }
246
247                         /*
248                          * Restore the reference 'Val' to the
249                          * initial value
250                          */
251
252                         Val = ~(1 << J);
253
254                         /* Read the values from each location that was
255                          * written */
256                         for (I = 0L; I < 32; I++) {
257                                 /* read memory location */
258                                 Word = Addr[I];
259                                 if (Word != Val) {
260                                         return -1;
261                                 }
262                                 Val = ~((u32)RotateLeft(~Val, 32));
263                         }
264
265                 }
266
267                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
268                         return 0;
269                 }
270
271                 /* end of case 3 */
272
273                 /* fall through case statement */
274
275         case XIL_TESTMEM_INVERSEADDR:
276                 /* Fill the memory with inverse of address */
277                 for (I = 0L; I < Words; I++) {
278                         /* write memory location */
279                         Val = (u32) (~((u32) (&Addr[I])));
280                         Addr[I] = Val;
281                 }
282
283                 /*
284                  * Check every word within the words
285                  * of tested memory
286                  */
287
288                 for (I = 0L; I < Words; I++) {
289                         /* Read the location */
290                         Word = Addr[I];
291                         Val = (u32) (~((u32) (&Addr[I])));
292
293                         if ((Word ^ Val) != 0x00000000) {
294                                 return -1;
295                         }
296                 }
297
298                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
299                         return 0;
300                 }
301                 /* end of case 4 */
302
303                 /* fall through case statement */
304
305         case XIL_TESTMEM_FIXEDPATTERN:
306                 /*
307                  * Generate an initial value for
308                  * memory testing
309                  */
310
311                 if (Pattern == 0) {
312                         Val = 0xDEADBEEF;
313                 }
314                 else {
315                         Val = Pattern;
316                 }
317
318                 /*
319                  * Fill the memory with fixed Pattern
320                  */
321
322                 for (I = 0L; I < Words; I++) {
323                         /* write memory location */
324                         Addr[I] = Val;
325                 }
326
327                 /*
328                  * Check every word within the words
329                  * of tested memory and compare it
330                  * with the fixed Pattern
331                  */
332
333                 for (I = 0L; I < Words; I++) {
334
335                         /* read memory location */
336
337                         Word = Addr[I];
338                         if (Word != Val) {
339                                 return -1;
340                         }
341                 }
342
343                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
344                         return 0;
345                 }
346                 /* end of case 5 */
347
348                 /* this break is for the prior fall through case statements */
349
350                 break;
351
352         default:
353                 return -1;
354
355         }                       /* end of switch */
356
357         /* Successfully passed memory test ! */
358
359         return 0;
360 }
361
362 /*****************************************************************************/
363 /**
364 *
365 * Perform a destructive 16-bit wide memory test.
366 *
367 * @param    Addr is a pointer to the region of memory to be tested.
368 * @param    Words is the length of the block.
369 * @param    Pattern is the constant used for the constant Pattern test, if 0,
370 *           0xDEADBEEF is used.
371 * @param    Subtest is the test selected. See xil_testmem.h for possible
372 *           values.
373 *
374 * @return
375 *
376 * - -1 is returned for a failure
377 * - 0 is returned for a pass
378 *
379 * @note
380 *
381 * Used for spaces where the address range of the region is smaller than
382 * the data width. If the memory range is greater than 2 ** Width,
383 * the patterns used in XIL_TESTMEM_WALKONES and XIL_TESTMEM_WALKZEROS will
384 * repeat on a boundry of a power of two making it more difficult to detect
385 * addressing errors. The XIL_TESTMEM_INCREMENT and XIL_TESTMEM_INVERSEADDR
386 * tests suffer the same problem. Ideally, if large blocks of memory are to be
387 * tested, break them up into smaller regions of memory to allow the test
388 * patterns used not to repeat over the region tested.
389 *
390 *****************************************************************************/
391 int Xil_TestMem16(u16 *Addr, u32 Words, u16 Pattern, u8 Subtest)
392 {
393         u32 I;
394         u32 J;
395         u16 Val;
396         u16 FirtVal;
397         u16 Word;
398
399         Xil_AssertNonvoid(Words != 0);
400         Xil_AssertNonvoid(Subtest <= XIL_TESTMEM_MAXTEST);
401
402         /*
403          * variable initialization
404          */
405         Val = XIL_TESTMEM_INIT_VALUE;
406         FirtVal = XIL_TESTMEM_INIT_VALUE;
407
408         /*
409          * selectthe proper Subtest(s)
410          */
411
412         switch (Subtest) {
413
414         case XIL_TESTMEM_ALLMEMTESTS:
415
416                 /* this case executes all of the Subtests */
417
418                 /* fall through case statement */
419
420         case XIL_TESTMEM_INCREMENT:
421                 /*
422                  * Fill the memory with incrementing
423                  * values starting from 'FirtVal'
424                  */
425                 for (I = 0L; I < Words; I++) {
426                         /* write memory location */
427                         Addr[I] = Val;
428                         Val++;
429                 }
430                 /*
431                  * Restore the reference 'Val' to the
432                  * initial value
433                  */
434                 Val = FirtVal;
435
436                 /*
437                  * Check every word within the words
438                  * of tested memory and compare it
439                  * with the incrementing reference val
440                  */
441
442                 for (I = 0L; I < Words; I++) {
443                         /* read memory location */
444                         Word = Addr[I];
445                         if (Word != Val) {
446                                 return -1;
447                         }
448                         Val++;
449                 }
450                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
451                         return 0;
452                 }
453
454                 /* end of case 1 */
455                 /* fall through case statement */
456
457         case XIL_TESTMEM_WALKONES:
458                 /*
459                  * set up to cycle through all possible initial test
460                  * Patterns for walking ones test
461                  */
462
463                 for (J = 0L; J < 16; J++) {
464                         /*
465                          * Generate an initial value for walking ones test
466                          * to test for bad data bits
467                          */
468
469                         Val = 1 << J;
470                         /*
471                          * START walking ones test
472                          * Write a one to each data bit indifferent locations
473                          */
474
475                         for (I = 0L; I < 16; I++) {
476                                 /* write memory location */
477                                 Addr[I] = Val;
478                                 Val = (u16)RotateLeft(Val, 16);
479                         }
480                         /*
481                          * Restore the reference 'Val' to the
482                          * initial value
483                          */
484                         Val = 1 << J;
485                         /* Read the values from each location that was written */
486                         for (I = 0L; I < 16; I++) {
487                                 /* read memory location */
488                                 Word = Addr[I];
489                                 if (Word != Val) {
490                                         return -1;
491                                 }
492                                 Val = (u16)RotateLeft(Val, 16);
493                         }
494
495                 }
496                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
497                         return 0;
498                 }
499                 /* end of case 2 */
500                 /* fall through case statement */
501
502         case XIL_TESTMEM_WALKZEROS:
503                 /*
504                  * set up to cycle through all possible initial
505                  * test Patterns for walking zeros test
506                  */
507
508                 for (J = 0L; J < 16; J++) {
509                         /*
510                          * Generate an initial value for walking ones
511                          * test to test for bad
512                          * data bits
513                          */
514
515                         Val = ~(1 << J);
516                         /*
517                          * START walking zeros test
518                          * Write a one to each data bit indifferent locations
519                          */
520
521                         for (I = 0L; I < 16; I++) {
522                                 /* write memory location */
523                                 Addr[I] = Val;
524                                 Val = ~((u16)RotateLeft(~Val, 16));
525                         }
526                         /*
527                          * Restore the reference 'Val' to the
528                          * initial value
529                          */
530                         Val = ~(1 << J);
531                         /* Read the values from each location that was written */
532                         for (I = 0L; I < 16; I++) {
533                                 /* read memory location */
534                                 Word = Addr[I];
535                                 if (Word != Val) {
536                                         return -1;
537                                 }
538                                 Val = ~((u16)RotateLeft(~Val, 16));
539                         }
540
541                 }
542                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
543                         return 0;
544                 }
545                 /* end of case 3 */
546                 /* fall through case statement */
547
548         case XIL_TESTMEM_INVERSEADDR:
549                 /* Fill the memory with inverse of address */
550                 for (I = 0L; I < Words; I++) {
551                         /* write memory location */
552                         Val = (u16) (~((u32) (&Addr[I])));
553                         Addr[I] = Val;
554                 }
555                 /*
556                  * Check every word within the words
557                  * of tested memory
558                  */
559
560                 for (I = 0L; I < Words; I++) {
561                         /* read memory location */
562                         Word = Addr[I];
563                         Val = (u16) (~((u32) (&Addr[I])));
564                         if ((Word ^ Val) != 0x0000) {
565                                 return -1;
566                         }
567                 }
568                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
569                         return 0;
570                 }
571                 /* end of case 4 */
572                 /* fall through case statement */
573
574         case XIL_TESTMEM_FIXEDPATTERN:
575                 /*
576                  * Generate an initial value for
577                  * memory testing
578                  */
579                 if (Pattern == 0) {
580                         Val = 0xDEAD;
581                 }
582                 else {
583                         Val = Pattern;
584                 }
585
586                 /*
587                  * Fill the memory with fixed pattern
588                  */
589
590                 for (I = 0L; I < Words; I++) {
591                         /* write memory location */
592                         Addr[I] = Val;
593                 }
594
595                 /*
596                  * Check every word within the words
597                  * of tested memory and compare it
598                  * with the fixed pattern
599                  */
600
601                 for (I = 0L; I < Words; I++) {
602                         /* read memory location */
603                         Word = Addr[I];
604                         if (Word != Val) {
605                                 return -1;
606                         }
607                 }
608                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
609                         return 0;
610                 }
611                 /* end of case 5 */
612                 /* this break is for the prior fall through case statements */
613
614                 break;
615
616         default:
617                 return -1;
618
619         }                       /* end of switch */
620
621         /* Successfully passed memory test ! */
622
623         return 0;
624 }
625
626
627 /*****************************************************************************/
628 /**
629 *
630 * Perform a destructive 8-bit wide memory test.
631 *
632 * @param    Addr is a pointer to the region of memory to be tested.
633 * @param    Words is the length of the block.
634 * @param    Pattern is the constant used for the constant pattern test, if 0,
635 *           0xDEADBEEF is used.
636 * @param    Subtest is the test selected. See xil_testmem.h for possible
637 *           values.
638 *
639 * @return
640 *
641 * - -1 is returned for a failure
642 * - 0 is returned for a pass
643 *
644 * @note
645 *
646 * Used for spaces where the address range of the region is smaller than
647 * the data width. If the memory range is greater than 2 ** Width,
648 * the patterns used in XIL_TESTMEM_WALKONES and XIL_TESTMEM_WALKZEROS will
649 * repeat on a boundry of a power of two making it more difficult to detect
650 * addressing errors. The XIL_TESTMEM_INCREMENT and XIL_TESTMEM_INVERSEADDR
651 * tests suffer the same problem. Ideally, if large blocks of memory are to be
652 * tested, break them up into smaller regions of memory to allow the test
653 * patterns used not to repeat over the region tested.
654 *
655 *****************************************************************************/
656 int Xil_TestMem8(u8 *Addr, u32 Words, u8 Pattern, u8 Subtest)
657 {
658         u32 I;
659         u32 J;
660         u8 Val;
661         u8 FirtVal;
662         u8 Word;
663
664         Xil_AssertNonvoid(Words != 0);
665         Xil_AssertNonvoid(Subtest <= XIL_TESTMEM_MAXTEST);
666
667         /*
668          * variable initialization
669          */
670         Val = XIL_TESTMEM_INIT_VALUE;
671         FirtVal = XIL_TESTMEM_INIT_VALUE;
672
673         /*
674          * select the proper Subtest(s)
675          */
676
677         switch (Subtest) {
678
679         case XIL_TESTMEM_ALLMEMTESTS:
680                 /* this case executes all of the Subtests */
681                 /* fall through case statement */
682
683         case XIL_TESTMEM_INCREMENT:
684                 /*
685                  * Fill the memory with incrementing
686                  * values starting from 'FirtVal'
687                  */
688                 for (I = 0L; I < Words; I++) {
689                         /* write memory location */
690                         Addr[I] = Val;
691                         Val++;
692                 }
693                 /*
694                  * Restore the reference 'Val' to the
695                  * initial value
696                  */
697                 Val = FirtVal;
698                 /*
699                  * Check every word within the words
700                  * of tested memory and compare it
701                  * with the incrementing reference
702                  * Val
703                  */
704
705                 for (I = 0L; I < Words; I++) {
706                         /* read memory location */
707                         Word = Addr[I];
708                         if (Word != Val) {
709                                 return -1;
710                         }
711                         Val++;
712                 }
713
714                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
715                         return 0;
716                 }
717                 /* end of case 1 */
718
719                 /* fall through case statement */
720
721         case XIL_TESTMEM_WALKONES:
722                 /*
723                  * set up to cycle through all possible initial
724                  * test Patterns for walking ones test
725                  */
726
727                 for (J = 0L; J < 8; J++) {
728                         /*
729                          * Generate an initial value for walking ones test
730                          * to test for bad data bits
731                          */
732                         Val = 1 << J;
733                         /*
734                          * START walking ones test
735                          * Write a one to each data bit indifferent locations
736                          */
737                         for (I = 0L; I < 8; I++) {
738                                 /* write memory location */
739                                 Addr[I] = Val;
740                                 Val = (u8)RotateLeft(Val, 8);
741                         }
742                         /*
743                          * Restore the reference 'Val' to the
744                          * initial value
745                          */
746                         Val = 1 << J;
747                         /* Read the values from each location that was written */
748                         for (I = 0L; I < 8; I++) {
749                                 /* read memory location */
750                                 Word = Addr[I];
751                                 if (Word != Val) {
752                                         return -1;
753                                 }
754                                 Val = (u8)RotateLeft(Val, 8);
755                         }
756                 }
757
758                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
759                         return 0;
760                 }
761                 /* end of case 2 */
762                 /* fall through case statement */
763
764         case XIL_TESTMEM_WALKZEROS:
765                 /*
766                  * set up to cycle through all possible initial test
767                  * Patterns for walking zeros test
768                  */
769
770                 for (J = 0L; J < 8; J++) {
771                         /*
772                          * Generate an initial value for walking ones test to test
773                          * for bad data bits
774                          */
775                         Val = ~(1 << J);
776                         /*
777                          * START walking zeros test
778                          * Write a one to each data bit indifferent locations
779                          */
780                         for (I = 0L; I < 8; I++) {
781                                 /* write memory location */
782                                 Addr[I] = Val;
783                                 Val = ~((u8)RotateLeft(~Val, 8));
784                         }
785                         /*
786                          * Restore the reference 'Val' to the
787                          * initial value
788                          */
789                         Val = ~(1 << J);
790                         /* Read the values from each location that was written */
791                         for (I = 0L; I < 8; I++) {
792                                 /* read memory location */
793                                 Word = Addr[I];
794                                 if (Word != Val) {
795                                         return -1;
796                                 }
797
798                                 Val = ~((u8)RotateLeft(~Val, 8));
799                         }
800                 }
801
802                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
803                         return 0;
804                 }
805                 /* end of case 3 */
806                 /* fall through case statement */
807
808         case XIL_TESTMEM_INVERSEADDR:
809                 /* Fill the memory with inverse of address */
810                 for (I = 0L; I < Words; I++) {
811                         /* write memory location */
812                         Val = (u8) (~((u32) (&Addr[I])));
813                         Addr[I] = Val;
814                 }
815
816                 /*
817                  * Check every word within the words
818                  * of tested memory
819                  */
820
821                 for (I = 0L; I < Words; I++) {
822                         /* read memory location */
823                         Word = Addr[I];
824                         Val = (u8) (~((u32) (&Addr[I])));
825                         if ((Word ^ Val) != 0x00) {
826                                 return -1;
827                         }
828                 }
829                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
830                         return 0;
831                 }
832                 /* end of case 4 */
833                 /* fall through case statement */
834
835         case XIL_TESTMEM_FIXEDPATTERN:
836                 /*
837                  * Generate an initial value for
838                  * memory testing
839                  */
840
841                 if (Pattern == 0) {
842                         Val = 0xA5;
843                 }
844                 else {
845                         Val = Pattern;
846                 }
847                 /*
848                  * Fill the memory with fixed Pattern
849                  */
850                 for (I = 0L; I < Words; I++) {
851                         /* write memory location */
852                         Addr[I] = Val;
853                 }
854                 /*
855                  * Check every word within the words
856                  * of tested memory and compare it
857                  * with the fixed Pattern
858                  */
859
860                 for (I = 0L; I < Words; I++) {
861                         /* read memory location */
862                         Word = Addr[I];
863                         if (Word != Val) {
864                                 return -1;
865                         }
866                 }
867
868                 if (Subtest != XIL_TESTMEM_ALLMEMTESTS) {
869                         return 0;
870                 }
871
872                 /* end of case 5 */
873
874                 /* this break is for the prior fall through case statements */
875
876                 break;
877
878         default:
879                 return -1;
880
881         }       /* end of switch */
882
883         /* Successfully passed memory test ! */
884
885         return 0;
886 }
887
888
889 /*****************************************************************************/
890 /**
891 *
892 * Rotates the provided value to the left one bit position
893 *
894 * @param    Input is value to be rotated to the left
895 * @param    Width is the number of bits in the input data
896 *
897 * @return
898 *
899 * The resulting unsigned long value of the rotate left
900 *
901 * @note
902 *
903 * None.
904 *
905 *****************************************************************************/
906 static u32 RotateLeft(u32 Input, u8 Width)
907 {
908         u32 Msb;
909         u32 ReturnVal;
910         u32 WidthMask;
911         u32 MsbMask;
912
913         /*
914          * set up the WidthMask and the MsbMask
915          */
916
917         MsbMask = 1 << (Width - 1);
918
919         WidthMask = (MsbMask << 1) - 1;
920
921         /*
922          * set the Width of the Input to the correct width
923          */
924
925         Input = Input & WidthMask;
926
927         Msb = Input & MsbMask;
928
929         ReturnVal = Input << 1;
930
931         if (Msb != 0x00000000) {
932                 ReturnVal = ReturnVal | 0x00000001;
933         }
934
935         ReturnVal = ReturnVal & WidthMask;
936
937         return ReturnVal;
938
939 }
940
941 #ifdef ROTATE_RIGHT
942 /*****************************************************************************/
943 /**
944 *
945 * Rotates the provided value to the right one bit position
946 *
947 * @param    Input is value to be rotated to the right
948 * @param    Width is the number of bits in the input data
949 *
950 * @return
951 *
952 * The resulting u32 value of the rotate right
953 *
954 * @note
955 *
956 * None.
957 *
958 *****************************************************************************/
959 static u32 RotateRight(u32 Input, u8 Width)
960 {
961         u32 Lsb;
962         u32 ReturnVal;
963         u32 WidthMask;
964         u32 MsbMask;
965
966         /*
967          * set up the WidthMask and the MsbMask
968          */
969
970         MsbMask = 1 << (Width - 1);
971
972         WidthMask = (MsbMask << 1) - 1;
973
974         /*
975          * set the width of the input to the correct width
976          */
977
978         Input = Input & WidthMask;
979
980         ReturnVal = Input >> 1;
981
982         Lsb = Input & 0x00000001;
983
984         if (Lsb != 0x00000000) {
985                 ReturnVal = ReturnVal | MsbMask;
986         }
987
988         ReturnVal = ReturnVal & WidthMask;
989
990         return ReturnVal;
991
992 }
993 #endif /* ROTATE_RIGHT */
994