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