2 * Copyright 2008 Michael Ellerman, IBM Corporation.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
11 #include <asm/feature-fixups.h>
12 #include <asm/ppc_asm.h>
13 #include <asm/synch.h>
21 globl(ftr_fixup_test1)
23 or 2,2,2 /* fixup will nop out this instruction */
26 globl(end_ftr_fixup_test1)
28 globl(ftr_fixup_test1_orig)
33 globl(ftr_fixup_test1_expected)
38 globl(ftr_fixup_test2)
40 or 2,2,2 /* fixup will replace this with ftr_fixup_test2_alt */
43 globl(end_ftr_fixup_test2)
45 globl(ftr_fixup_test2_orig)
50 globl(ftr_fixup_test2_alt)
53 globl(ftr_fixup_test2_expected)
58 globl(ftr_fixup_test3)
60 or 2,2,2 /* fixup will fail to replace this */
63 globl(end_ftr_fixup_test3)
65 globl(ftr_fixup_test3_orig)
70 globl(ftr_fixup_test3_alt)
74 globl(ftr_fixup_test4)
82 globl(end_ftr_fixup_test4)
84 globl(ftr_fixup_test4_expected)
92 globl(ftr_fixup_test4_orig)
100 globl(ftr_fixup_test4_alt)
105 globl(ftr_fixup_test5)
123 ALT_FTR_SECTION_END(0, 1)
126 globl(end_ftr_fixup_test5)
128 globl(ftr_fixup_test5_expected)
139 globl(ftr_fixup_test6)
155 ALT_FTR_SECTION_END(0, 1)
160 globl(end_ftr_fixup_test6)
162 globl(ftr_fixup_test6_expected)
175 #define MAKE_MACRO_TEST(TYPE) \
176 globl(ftr_fixup_test_ ##TYPE##_macros) \
178 /* Basic test, this section should all be nop'ed */ \
179 BEGIN_##TYPE##_SECTION \
183 END_##TYPE##_SECTION(0, 1) \
186 /* Basic test, this section should NOT be nop'ed */ \
187 BEGIN_##TYPE##_SECTION \
191 END_##TYPE##_SECTION(0, 0) \
194 /* Nesting test, inner section should be nop'ed */ \
195 BEGIN_##TYPE##_SECTION \
198 BEGIN_##TYPE##_SECTION_NESTED(80) \
201 END_##TYPE##_SECTION_NESTED(0, 1, 80) \
204 END_##TYPE##_SECTION(0, 0) \
207 /* Nesting test, whole section should be nop'ed */ \
208 BEGIN_##TYPE##_SECTION \
211 BEGIN_##TYPE##_SECTION_NESTED(80) \
214 END_##TYPE##_SECTION_NESTED(0, 0, 80) \
217 END_##TYPE##_SECTION(0, 1) \
220 /* Nesting test, none should be nop'ed */ \
221 BEGIN_##TYPE##_SECTION \
224 BEGIN_##TYPE##_SECTION_NESTED(80) \
227 END_##TYPE##_SECTION_NESTED(0, 0, 80) \
230 END_##TYPE##_SECTION(0, 0) \
233 /* Basic alt section test, default case should be taken */ \
234 BEGIN_##TYPE##_SECTION \
238 ##TYPE##_SECTION_ELSE \
241 ALT_##TYPE##_SECTION_END(0, 0) \
244 /* Basic alt section test, else case should be taken */ \
245 BEGIN_##TYPE##_SECTION \
249 ##TYPE##_SECTION_ELSE \
253 ALT_##TYPE##_SECTION_END(0, 1) \
256 /* Alt with smaller else case, should be padded with nops */ \
257 BEGIN_##TYPE##_SECTION \
261 ##TYPE##_SECTION_ELSE \
263 ALT_##TYPE##_SECTION_END(0, 1) \
266 /* Alt section with nested section in default case */ \
267 /* Default case should be taken, with nop'ed inner section */ \
268 BEGIN_##TYPE##_SECTION \
270 BEGIN_##TYPE##_SECTION_NESTED(95) \
273 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
275 ##TYPE##_SECTION_ELSE \
278 ALT_##TYPE##_SECTION_END(0, 0) \
281 /* Alt section with nested section in else, default taken */ \
282 BEGIN_##TYPE##_SECTION \
286 ##TYPE##_SECTION_ELSE \
288 BEGIN_##TYPE##_SECTION_NESTED(95) \
290 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
292 ALT_##TYPE##_SECTION_END(0, 0) \
295 /* Alt section with nested section in else, else taken & nop */ \
296 BEGIN_##TYPE##_SECTION \
300 ##TYPE##_SECTION_ELSE \
302 BEGIN_##TYPE##_SECTION_NESTED(95) \
304 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
306 ALT_##TYPE##_SECTION_END(0, 1) \
309 /* Feature section with nested alt section, default taken */ \
310 BEGIN_##TYPE##_SECTION \
312 BEGIN_##TYPE##_SECTION_NESTED(95) \
314 ##TYPE##_SECTION_ELSE_NESTED(95) \
316 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
318 END_##TYPE##_SECTION(0, 0) \
321 /* Feature section with nested alt section, else taken */ \
322 BEGIN_##TYPE##_SECTION \
324 BEGIN_##TYPE##_SECTION_NESTED(95) \
326 ##TYPE##_SECTION_ELSE_NESTED(95) \
328 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
330 END_##TYPE##_SECTION(0, 0) \
333 /* Feature section with nested alt section, all nop'ed */ \
334 BEGIN_##TYPE##_SECTION \
336 BEGIN_##TYPE##_SECTION_NESTED(95) \
338 ##TYPE##_SECTION_ELSE_NESTED(95) \
340 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
342 END_##TYPE##_SECTION(0, 1) \
345 /* Nested alt sections, default with inner default taken */ \
346 BEGIN_##TYPE##_SECTION \
348 BEGIN_##TYPE##_SECTION_NESTED(95) \
350 ##TYPE##_SECTION_ELSE_NESTED(95) \
352 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
354 ##TYPE##_SECTION_ELSE \
356 BEGIN_##TYPE##_SECTION_NESTED(94) \
358 ##TYPE##_SECTION_ELSE_NESTED(94) \
360 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
362 ALT_##TYPE##_SECTION_END(0, 0) \
365 /* Nested alt sections, default with inner else taken */ \
366 BEGIN_##TYPE##_SECTION \
368 BEGIN_##TYPE##_SECTION_NESTED(95) \
370 ##TYPE##_SECTION_ELSE_NESTED(95) \
372 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
374 ##TYPE##_SECTION_ELSE \
376 BEGIN_##TYPE##_SECTION_NESTED(94) \
378 ##TYPE##_SECTION_ELSE_NESTED(94) \
380 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
382 ALT_##TYPE##_SECTION_END(0, 0) \
385 /* Nested alt sections, else with inner default taken */ \
386 BEGIN_##TYPE##_SECTION \
388 BEGIN_##TYPE##_SECTION_NESTED(95) \
390 ##TYPE##_SECTION_ELSE_NESTED(95) \
392 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
394 ##TYPE##_SECTION_ELSE \
396 BEGIN_##TYPE##_SECTION_NESTED(94) \
398 ##TYPE##_SECTION_ELSE_NESTED(94) \
400 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
402 ALT_##TYPE##_SECTION_END(0, 1) \
405 /* Nested alt sections, else with inner else taken */ \
406 BEGIN_##TYPE##_SECTION \
408 BEGIN_##TYPE##_SECTION_NESTED(95) \
410 ##TYPE##_SECTION_ELSE_NESTED(95) \
412 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
414 ##TYPE##_SECTION_ELSE \
416 BEGIN_##TYPE##_SECTION_NESTED(94) \
418 ##TYPE##_SECTION_ELSE_NESTED(94) \
420 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) \
422 ALT_##TYPE##_SECTION_END(0, 1) \
425 /* Nested alt sections, else can have large else case */ \
426 BEGIN_##TYPE##_SECTION \
431 ##TYPE##_SECTION_ELSE \
432 BEGIN_##TYPE##_SECTION_NESTED(94) \
437 ##TYPE##_SECTION_ELSE_NESTED(94) \
442 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) \
443 ALT_##TYPE##_SECTION_END(0, 1) \
447 #define MAKE_MACRO_TEST_EXPECTED(TYPE) \
448 globl(ftr_fixup_test_ ##TYPE##_macros_expected) \
450 /* Basic test, this section should all be nop'ed */ \
451 /* BEGIN_##TYPE##_SECTION */ \
455 /* END_##TYPE##_SECTION(0, 1) */ \
458 /* Basic test, this section should NOT be nop'ed */ \
459 /* BEGIN_##TYPE##_SECTION */ \
463 /* END_##TYPE##_SECTION(0, 0) */ \
466 /* Nesting test, inner section should be nop'ed */ \
467 /* BEGIN_##TYPE##_SECTION */ \
470 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
473 /* END_##TYPE##_SECTION_NESTED(0, 1, 80) */ \
476 /* END_##TYPE##_SECTION(0, 0) */ \
479 /* Nesting test, whole section should be nop'ed */ \
480 /* NB. inner section is not nop'ed, but then entire outer is */ \
481 /* BEGIN_##TYPE##_SECTION */ \
484 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
487 /* END_##TYPE##_SECTION_NESTED(0, 0, 80) */ \
490 /* END_##TYPE##_SECTION(0, 1) */ \
493 /* Nesting test, none should be nop'ed */ \
494 /* BEGIN_##TYPE##_SECTION */ \
497 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
500 /* END_##TYPE##_SECTION_NESTED(0, 0, 80) */ \
503 /* END_##TYPE##_SECTION(0, 0) */ \
506 /* Basic alt section test, default case should be taken */ \
507 /* BEGIN_##TYPE##_SECTION */ \
511 /* ##TYPE##_SECTION_ELSE */ \
514 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
517 /* Basic alt section test, else case should be taken */ \
518 /* BEGIN_##TYPE##_SECTION */ \
522 /* ##TYPE##_SECTION_ELSE */ \
526 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
529 /* Alt with smaller else case, should be padded with nops */ \
530 /* BEGIN_##TYPE##_SECTION */ \
534 /* ##TYPE##_SECTION_ELSE */ \
538 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
541 /* Alt section with nested section in default case */ \
542 /* Default case should be taken, with nop'ed inner section */ \
543 /* BEGIN_##TYPE##_SECTION */ \
545 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
548 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
550 /* ##TYPE##_SECTION_ELSE */ \
553 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
556 /* Alt section with nested section in else, default taken */ \
557 /* BEGIN_##TYPE##_SECTION */ \
561 /* ##TYPE##_SECTION_ELSE */ \
563 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
565 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
567 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
570 /* Alt section with nested section in else, else taken & nop */ \
571 /* BEGIN_##TYPE##_SECTION */ \
575 /* ##TYPE##_SECTION_ELSE */ \
577 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
579 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
581 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
584 /* Feature section with nested alt section, default taken */ \
585 /* BEGIN_##TYPE##_SECTION */ \
587 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
589 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
591 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
593 /* END_##TYPE##_SECTION(0, 0) */ \
596 /* Feature section with nested alt section, else taken */ \
597 /* BEGIN_##TYPE##_SECTION */ \
599 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
601 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
603 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
605 /* END_##TYPE##_SECTION(0, 0) */ \
608 /* Feature section with nested alt section, all nop'ed */ \
609 /* BEGIN_##TYPE##_SECTION */ \
611 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
613 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
615 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
617 /* END_##TYPE##_SECTION(0, 1) */ \
620 /* Nested alt sections, default with inner default taken */ \
621 /* BEGIN_##TYPE##_SECTION */ \
623 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
625 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
627 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
629 /* ##TYPE##_SECTION_ELSE */ \
631 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
633 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
635 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
637 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
640 /* Nested alt sections, default with inner else taken */ \
641 /* BEGIN_##TYPE##_SECTION */ \
643 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
645 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
647 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
649 /* ##TYPE##_SECTION_ELSE */ \
651 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
653 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
655 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
657 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
660 /* Nested alt sections, else with inner default taken */ \
661 /* BEGIN_##TYPE##_SECTION */ \
663 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
665 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
667 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
669 /* ##TYPE##_SECTION_ELSE */ \
671 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
673 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
675 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
677 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
680 /* Nested alt sections, else with inner else taken */ \
681 /* BEGIN_##TYPE##_SECTION */ \
683 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
685 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
687 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
689 /* ##TYPE##_SECTION_ELSE */ \
691 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
693 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
695 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */ \
697 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
700 /* Nested alt sections, else can have large else case */ \
701 /* BEGIN_##TYPE##_SECTION */ \
706 /* ##TYPE##_SECTION_ELSE */ \
707 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
712 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
717 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */ \
718 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
722 MAKE_MACRO_TEST(FTR);
723 MAKE_MACRO_TEST_EXPECTED(FTR);
726 MAKE_MACRO_TEST(FW_FTR);
727 MAKE_MACRO_TEST_EXPECTED(FW_FTR);
730 globl(lwsync_fixup_test)
733 globl(end_lwsync_fixup_test)
735 globl(lwsync_fixup_test_expected_LWSYNC)
739 globl(lwsync_fixup_test_expected_SYNC)