]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/libsrc/standalone_v5_0/src/xil_testmem.c
Add in the CORTEX_A53_64-bit_UltraScale_MPSoC demo application (a demo has been inclu...
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / libsrc / standalone_v5_0 / 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 s32 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 WordMem32;
102         s32 Status = 0;
103
104         Xil_AssertNonvoid(Words != (u32)0);
105         Xil_AssertNonvoid(Subtest <= (u8)XIL_TESTMEM_MAXTEST);
106         Xil_AssertNonvoid(Addr != NULL);
107
108         /*
109          * variable initialization
110          */
111         Val = XIL_TESTMEM_INIT_VALUE;
112         FirtVal = XIL_TESTMEM_INIT_VALUE;
113
114
115         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_INCREMENT)) {
116                 /*
117                  * Fill the memory with incrementing
118                  * values starting from 'FirtVal'
119                  */
120                 for (I = 0U; I < Words; I++) {
121                         *(Addr+I) = Val;
122                         Val++;
123                 }
124
125                 /*
126                  * Restore the reference 'Val' to the
127                  * initial value
128                  */
129                 Val = FirtVal;
130
131                 /*
132                  * Check every word within the words
133                  * of tested memory and compare it
134                  * with the incrementing reference
135                  * Val
136                  */
137
138                 for (I = 0U; I < Words; I++) {
139                         WordMem32 = *(Addr+I);
140
141                         if (WordMem32 != Val) {
142                                 Status = -1;
143                                 goto End_Label;
144                         }
145
146                         Val++;
147                 }
148         }
149
150         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_WALKONES)) {
151                 /*
152                  * set up to cycle through all possible initial
153                  * test Patterns for walking ones test
154                  */
155
156                 for (j = 0U; j < (u32)32; j++) {
157                         /*
158                          * Generate an initial value for walking ones test
159                          * to test for bad data bits
160                          */
161
162                         Val = (1U << j);
163
164                         /*
165                          * START walking ones test
166                          * Write a one to each data bit indifferent locations
167                          */
168
169                         for (I = 0U; I < (u32)32; I++) {
170                                 /* write memory location */
171                                 *(Addr+I) = Val;
172                                 Val = (u32) RotateLeft(Val, 32U);
173                         }
174
175                         /*
176                          * Restore the reference 'val' to the
177                          * initial value
178                          */
179                         Val = 1U << j;
180
181                         /* Read the values from each location that was
182                          * written */
183                         for (I = 0U; I < (u32)32; I++) {
184                                 /* read memory location */
185
186                                 WordMem32 = *(Addr+I);
187
188                                 if (WordMem32 != Val) {
189                                         Status = -1;
190                                         goto End_Label;
191                                 }
192
193                                 Val = (u32)RotateLeft(Val, 32U);
194                         }
195                 }
196         }
197
198         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_WALKZEROS)) {
199                 /*
200                  * set up to cycle through all possible
201                  * initial test Patterns for walking zeros test
202                  */
203
204                 for (j = 0U; j < (u32)32; j++) {
205
206                         /*
207                          * Generate an initial value for walking ones test
208                          * to test for bad data bits
209                          */
210
211                         Val = ~(1U << j);
212
213                         /*
214                          * START walking zeros test
215                          * Write a one to each data bit indifferent locations
216                          */
217
218                         for (I = 0U; I < (u32)32; I++) {
219                                 /* write memory location */
220                                 *(Addr+I) = Val;
221                                 Val = ~((u32)RotateLeft(~Val, 32U));
222                         }
223
224                         /*
225                          * Restore the reference 'Val' to the
226                          * initial value
227                          */
228
229                         Val = ~(1U << j);
230
231                         /* Read the values from each location that was
232                          * written */
233                         for (I = 0U; I < (u32)32; I++) {
234                                 /* read memory location */
235                                 WordMem32 = *(Addr+I);
236                                 if (WordMem32 != Val) {
237                                         Status = -1;
238                                         goto End_Label;
239                                 }
240                                 Val = ~((u32)RotateLeft(~Val, 32U));
241                         }
242
243                 }
244         }
245
246         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_INVERSEADDR)) {
247                 /* Fill the memory with inverse of address */
248                 for (I = 0U; I < Words; I++) {
249                         /* write memory location */
250                         Val = (u32) (~((INTPTR) (&Addr[I])));
251                         *(Addr+I) = Val;
252                 }
253
254                 /*
255                  * Check every word within the words
256                  * of tested memory
257                  */
258
259                 for (I = 0U; I < Words; I++) {
260                         /* Read the location */
261                         WordMem32 = *(Addr+I);
262                         Val = (u32) (~((INTPTR) (&Addr[I])));
263
264                         if ((WordMem32 ^ Val) != 0x00000000U) {
265                                 Status = -1;
266                                 goto End_Label;
267                         }
268                 }
269         }
270
271         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_FIXEDPATTERN)) {
272                 /*
273                  * Generate an initial value for
274                  * memory testing
275                  */
276
277                 if (Pattern == (u32)0) {
278                         Val = 0xDEADBEEFU;
279                 }
280                 else {
281                         Val = Pattern;
282                 }
283
284                 /*
285                  * Fill the memory with fixed Pattern
286                  */
287
288                 for (I = 0U; I < Words; I++) {
289                         /* write memory location */
290                         *(Addr+I) = Val;
291                 }
292
293                 /*
294                  * Check every word within the words
295                  * of tested memory and compare it
296                  * with the fixed Pattern
297                  */
298
299                 for (I = 0U; I < Words; I++) {
300
301                         /* read memory location */
302
303                         WordMem32 = *(Addr+I);
304                         if (WordMem32 != Val) {
305                                 Status = -1;
306                                 goto End_Label;
307                         }
308                 }
309         }
310
311 End_Label:
312         return Status;
313 }
314
315 /*****************************************************************************/
316 /**
317 *
318 * Perform a destructive 16-bit wide memory test.
319 *
320 * @param    Addr is a pointer to the region of memory to be tested.
321 * @param    Words is the length of the block.
322 * @param    Pattern is the constant used for the constant Pattern test, if 0,
323 *           0xDEADBEEF is used.
324 * @param    Subtest is the test selected. See xil_testmem.h for possible
325 *           values.
326 *
327 * @return
328 *
329 * - -1 is returned for a failure
330 * - 0 is returned for a pass
331 *
332 * @note
333 *
334 * Used for spaces where the address range of the region is smaller than
335 * the data width. If the memory range is greater than 2 ** Width,
336 * the patterns used in XIL_TESTMEM_WALKONES and XIL_TESTMEM_WALKZEROS will
337 * repeat on a boundry of a power of two making it more difficult to detect
338 * addressing errors. The XIL_TESTMEM_INCREMENT and XIL_TESTMEM_INVERSEADDR
339 * tests suffer the same problem. Ideally, if large blocks of memory are to be
340 * tested, break them up into smaller regions of memory to allow the test
341 * patterns used not to repeat over the region tested.
342 *
343 *****************************************************************************/
344 s32 Xil_TestMem16(u16 *Addr, u32 Words, u16 Pattern, u8 Subtest)
345 {
346         u32 I;
347         u32 j;
348         u16 Val;
349         u16 FirtVal;
350         u16 WordMem16;
351         s32 Status = 0;
352
353         Xil_AssertNonvoid(Words != (u32)0);
354         Xil_AssertNonvoid(Subtest <= XIL_TESTMEM_MAXTEST);
355         Xil_AssertNonvoid(Addr != NULL);
356
357         /*
358          * variable initialization
359          */
360         Val = XIL_TESTMEM_INIT_VALUE;
361         FirtVal = XIL_TESTMEM_INIT_VALUE;
362
363         /*
364          * selectthe proper Subtest(s)
365          */
366
367         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_INCREMENT)) {
368                 /*
369                  * Fill the memory with incrementing
370                  * values starting from 'FirtVal'
371                  */
372                 for (I = 0U; I < Words; I++) {
373                         /* write memory location */
374                         *(Addr+I) = Val;
375                         Val++;
376                 }
377                 /*
378                  * Restore the reference 'Val' to the
379                  * initial value
380                  */
381                 Val = FirtVal;
382
383                 /*
384                  * Check every word within the words
385                  * of tested memory and compare it
386                  * with the incrementing reference val
387                  */
388
389                 for (I = 0U; I < Words; I++) {
390                         /* read memory location */
391                         WordMem16 = *(Addr+I);
392                         if (WordMem16 != Val) {
393                                 Status = -1;
394                                 goto End_Label;
395                         }
396                         Val++;
397                 }
398         }
399
400         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_WALKONES)) {
401                 /*
402                  * set up to cycle through all possible initial test
403                  * Patterns for walking ones test
404                  */
405
406                 for (j = 0U; j < (u32)16; j++) {
407                         /*
408                          * Generate an initial value for walking ones test
409                          * to test for bad data bits
410                          */
411
412                         Val = (u16)((u32)1 << j);
413                         /*
414                          * START walking ones test
415                          * Write a one to each data bit indifferent locations
416                          */
417
418                         for (I = 0U; I < (u32)16; I++) {
419                                 /* write memory location */
420                                 *(Addr+I) = Val;
421                                 Val = (u16)RotateLeft(Val, 16U);
422                         }
423                         /*
424                          * Restore the reference 'Val' to the
425                          * initial value
426                          */
427                         Val = (u16)((u32)1 << j);
428                         /* Read the values from each location that was written */
429                         for (I = 0U; I < (u32)16; I++) {
430                                 /* read memory location */
431                                 WordMem16 = *(Addr+I);
432                                 if (WordMem16 != Val) {
433                                         Status = -1;
434                                         goto End_Label;
435                                 }
436                                 Val = (u16)RotateLeft(Val, 16U);
437                         }
438                 }
439         }
440
441         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_WALKZEROS)) {
442                 /*
443                  * set up to cycle through all possible initial
444                  * test Patterns for walking zeros test
445                  */
446
447                 for (j = 0U; j < (u32)16; j++) {
448                         /*
449                          * Generate an initial value for walking ones
450                          * test to test for bad
451                          * data bits
452                          */
453
454                         Val = ~(1U << j);
455                         /*
456                          * START walking zeros test
457                          * Write a one to each data bit indifferent locations
458                          */
459
460                         for (I = 0U; I < (u32)16; I++) {
461                                 /* write memory location */
462                                 *(Addr+I) = Val;
463                                 Val = ~((u16)RotateLeft(~Val, 16U));
464                         }
465                         /*
466                          * Restore the reference 'Val' to the
467                          * initial value
468                          */
469                         Val = ~(1U << j);
470                         /* Read the values from each location that was written */
471                         for (I = 0U; I < (u32)16; I++) {
472                                 /* read memory location */
473                                 WordMem16 = *(Addr+I);
474                                 if (WordMem16 != Val) {
475                                         Status = -1;
476                                         goto End_Label;
477                                 }
478                                 Val = ~((u16)RotateLeft(~Val, 16U));
479                         }
480
481                 }
482         }
483
484         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_INVERSEADDR)) {
485                 /* Fill the memory with inverse of address */
486                 for (I = 0U; I < Words; I++) {
487                         /* write memory location */
488                         Val = (u16) (~((INTPTR)(&Addr[I])));
489                         *(Addr+I) = Val;
490                 }
491                 /*
492                  * Check every word within the words
493                  * of tested memory
494                  */
495
496                 for (I = 0U; I < Words; I++) {
497                         /* read memory location */
498                         WordMem16 = *(Addr+I);
499                         Val = (u16) (~((INTPTR) (&Addr[I])));
500                         if ((WordMem16 ^ Val) != 0x0000U) {
501                                 Status = -1;
502                                 goto End_Label;
503                         }
504                 }
505         }
506
507         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_FIXEDPATTERN)) {
508                 /*
509                  * Generate an initial value for
510                  * memory testing
511                  */
512                 if (Pattern == (u16)0) {
513                         Val = 0xDEADU;
514                 }
515                 else {
516                         Val = Pattern;
517                 }
518
519                 /*
520                  * Fill the memory with fixed pattern
521                  */
522
523                 for (I = 0U; I < Words; I++) {
524                         /* write memory location */
525                         *(Addr+I) = Val;
526                 }
527
528                 /*
529                  * Check every word within the words
530                  * of tested memory and compare it
531                  * with the fixed pattern
532                  */
533
534                 for (I = 0U; I < Words; I++) {
535                         /* read memory location */
536                         WordMem16 = *(Addr+I);
537                         if (WordMem16 != Val) {
538                                 Status = -1;
539                                 goto End_Label;
540                         }
541                 }
542         }
543
544 End_Label:
545         return Status;
546 }
547
548
549 /*****************************************************************************/
550 /**
551 *
552 * Perform a destructive 8-bit wide memory test.
553 *
554 * @param    Addr is a pointer to the region of memory to be tested.
555 * @param    Words is the length of the block.
556 * @param    Pattern is the constant used for the constant pattern test, if 0,
557 *           0xDEADBEEF is used.
558 * @param    Subtest is the test selected. See xil_testmem.h for possible
559 *           values.
560 *
561 * @return
562 *
563 * - -1 is returned for a failure
564 * - 0 is returned for a pass
565 *
566 * @note
567 *
568 * Used for spaces where the address range of the region is smaller than
569 * the data width. If the memory range is greater than 2 ** Width,
570 * the patterns used in XIL_TESTMEM_WALKONES and XIL_TESTMEM_WALKZEROS will
571 * repeat on a boundry of a power of two making it more difficult to detect
572 * addressing errors. The XIL_TESTMEM_INCREMENT and XIL_TESTMEM_INVERSEADDR
573 * tests suffer the same problem. Ideally, if large blocks of memory are to be
574 * tested, break them up into smaller regions of memory to allow the test
575 * patterns used not to repeat over the region tested.
576 *
577 *****************************************************************************/
578 s32 Xil_TestMem8(u8 *Addr, u32 Words, u8 Pattern, u8 Subtest)
579 {
580         u32 I;
581         u32 j;
582         u8 Val;
583         u8 FirtVal;
584         u8 WordMem8;
585         s32 Status = 0;
586
587         Xil_AssertNonvoid(Words != (u32)0);
588         Xil_AssertNonvoid(Subtest <= XIL_TESTMEM_MAXTEST);
589         Xil_AssertNonvoid(Addr != NULL);
590
591         /*
592          * variable initialization
593          */
594         Val = XIL_TESTMEM_INIT_VALUE;
595         FirtVal = XIL_TESTMEM_INIT_VALUE;
596
597         /*
598          * select the proper Subtest(s)
599          */
600
601         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_INCREMENT)) {
602                 /*
603                  * Fill the memory with incrementing
604                  * values starting from 'FirtVal'
605                  */
606                 for (I = 0U; I < Words; I++) {
607                         /* write memory location */
608                         *(Addr+I) = Val;
609                         Val++;
610                 }
611                 /*
612                  * Restore the reference 'Val' to the
613                  * initial value
614                  */
615                 Val = FirtVal;
616                 /*
617                  * Check every word within the words
618                  * of tested memory and compare it
619                  * with the incrementing reference
620                  * Val
621                  */
622
623                 for (I = 0U; I < Words; I++) {
624                         /* read memory location */
625                         WordMem8 = *(Addr+I);
626                         if (WordMem8 != Val) {
627                                 Status = -1;
628                                 goto End_Label;
629                         }
630                         Val++;
631                 }
632         }
633
634         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_WALKONES)) {
635                 /*
636                  * set up to cycle through all possible initial
637                  * test Patterns for walking ones test
638                  */
639
640                 for (j = 0U; j < (u32)8; j++) {
641                         /*
642                          * Generate an initial value for walking ones test
643                          * to test for bad data bits
644                          */
645                         Val = (u8)((u32)1 << j);
646                         /*
647                          * START walking ones test
648                          * Write a one to each data bit indifferent locations
649                          */
650                         for (I = 0U; I < (u32)8; I++) {
651                                 /* write memory location */
652                                 *(Addr+I) = Val;
653                                 Val = (u8)RotateLeft(Val, 8U);
654                         }
655                         /*
656                          * Restore the reference 'Val' to the
657                          * initial value
658                          */
659                         Val = (u8)((u32)1 << j);
660                         /* Read the values from each location that was written */
661                         for (I = 0U; I < (u32)8; I++) {
662                                 /* read memory location */
663                                 WordMem8 = *(Addr+I);
664                                 if (WordMem8 != Val) {
665                                         Status = -1;
666                                         goto End_Label;
667                                 }
668                                 Val = (u8)RotateLeft(Val, 8U);
669                         }
670                 }
671         }
672
673         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_WALKZEROS)) {
674                 /*
675                  * set up to cycle through all possible initial test
676                  * Patterns for walking zeros test
677                  */
678
679                 for (j = 0U; j < (u32)8; j++) {
680                         /*
681                          * Generate an initial value for walking ones test to test
682                          * for bad data bits
683                          */
684                         Val = ~(1U << j);
685                         /*
686                          * START walking zeros test
687                          * Write a one to each data bit indifferent locations
688                          */
689                         for (I = 0U; I < (u32)8; I++) {
690                                 /* write memory location */
691                                 *(Addr+I) = Val;
692                                 Val = ~((u8)RotateLeft(~Val, 8U));
693                         }
694                         /*
695                          * Restore the reference 'Val' to the
696                          * initial value
697                          */
698                         Val = ~(1U << j);
699                         /* Read the values from each location that was written */
700                         for (I = 0U; I < (u32)8; I++) {
701                                 /* read memory location */
702                                 WordMem8 = *(Addr+I);
703                                 if (WordMem8 != Val) {
704                                         Status = -1;
705                                         goto End_Label;
706                                 }
707
708                                 Val = ~((u8)RotateLeft(~Val, 8U));
709                         }
710                 }
711         }
712
713         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_INVERSEADDR)) {
714                 /* Fill the memory with inverse of address */
715                 for (I = 0U; I < Words; I++) {
716                         /* write memory location */
717                         Val = (u8) (~((INTPTR) (&Addr[I])));
718                         *(Addr+I) = Val;
719                 }
720
721                 /*
722                  * Check every word within the words
723                  * of tested memory
724                  */
725
726                 for (I = 0U; I < Words; I++) {
727                         /* read memory location */
728                         WordMem8 = *(Addr+I);
729                         Val = (u8) (~((INTPTR) (&Addr[I])));
730                         if ((WordMem8 ^ Val) != 0x00U) {
731                                 Status = -1;
732                                 goto End_Label;
733                         }
734                 }
735         }
736
737         if((Subtest == XIL_TESTMEM_ALLMEMTESTS) || (Subtest == XIL_TESTMEM_FIXEDPATTERN)) {
738                 /*
739                  * Generate an initial value for
740                  * memory testing
741                  */
742
743                 if (Pattern == (u8)0) {
744                         Val = 0xA5U;
745                 }
746                 else {
747                         Val = Pattern;
748                 }
749                 /*
750                  * Fill the memory with fixed Pattern
751                  */
752                 for (I = 0U; I < Words; I++) {
753                         /* write memory location */
754                         *(Addr+I) = Val;
755                 }
756                 /*
757                  * Check every word within the words
758                  * of tested memory and compare it
759                  * with the fixed Pattern
760                  */
761
762                 for (I = 0U; I < Words; I++) {
763                         /* read memory location */
764                         WordMem8 = *(Addr+I);
765                         if (WordMem8 != Val) {
766                                 Status = -1;
767                                 goto End_Label;
768                         }
769                 }
770         }
771
772 End_Label:
773         return Status;
774 }
775
776
777 /*****************************************************************************/
778 /**
779 *
780 * Rotates the provided value to the left one bit position
781 *
782 * @param    Input is value to be rotated to the left
783 * @param    Width is the number of bits in the input data
784 *
785 * @return
786 *
787 * The resulting unsigned long value of the rotate left
788 *
789 * @note
790 *
791 * None.
792 *
793 *****************************************************************************/
794 static u32 RotateLeft(u32 Input, u8 Width)
795 {
796         u32 Msb;
797         u32 ReturnVal;
798         u32 WidthMask;
799         u32 MsbMask;
800         u32 LocalInput = Input;
801
802         /*
803          * set up the WidthMask and the MsbMask
804          */
805
806         MsbMask = 1U << (Width - 1U);
807
808         WidthMask = (MsbMask << (u32)1) - (u32)1;
809
810         /*
811          * set the Width of the Input to the correct width
812          */
813
814         LocalInput = LocalInput & WidthMask;
815
816         Msb = LocalInput & MsbMask;
817
818         ReturnVal = LocalInput << 1U;
819
820         if (Msb != 0x00000000U) {
821                 ReturnVal = ReturnVal | (u32)0x00000001;
822         }
823
824         ReturnVal = ReturnVal & WidthMask;
825
826         return ReturnVal;
827
828 }
829
830 #ifdef ROTATE_RIGHT
831 /*****************************************************************************/
832 /**
833 *
834 * Rotates the provided value to the right one bit position
835 *
836 * @param    Input is value to be rotated to the right
837 * @param    Width is the number of bits in the input data
838 *
839 * @return
840 *
841 * The resulting u32 value of the rotate right
842 *
843 * @note
844 *
845 * None.
846 *
847 *****************************************************************************/
848 static u32 RotateRight(u32 Input, u8 Width)
849 {
850         u32 Lsb;
851         u32 ReturnVal;
852         u32 WidthMask;
853         u32 MsbMask;
854         u32 LocalInput = Input;
855         /*
856          * set up the WidthMask and the MsbMask
857          */
858
859         MsbMask = 1U << (Width - 1U);
860
861         WidthMask = (MsbMask << 1U) - 1U;
862
863         /*
864          * set the width of the input to the correct width
865          */
866
867         LocalInput = LocalInput & WidthMask;
868
869         ReturnVal = LocalInput >> 1U;
870
871         Lsb = LocalInput & 0x00000001U;
872
873         if (Lsb != 0x00000000U) {
874                 ReturnVal = ReturnVal | MsbMask;
875         }
876
877         ReturnVal = ReturnVal & WidthMask;
878
879         return ReturnVal;
880
881 }
882 #endif /* ROTATE_RIGHT */