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>
14 #include <asm/asm-compat.h>
22 globl(ftr_fixup_test1)
24 or 2,2,2 /* fixup will nop out this instruction */
27 globl(end_ftr_fixup_test1)
29 globl(ftr_fixup_test1_orig)
34 globl(ftr_fixup_test1_expected)
39 globl(ftr_fixup_test2)
41 or 2,2,2 /* fixup will replace this with ftr_fixup_test2_alt */
44 globl(end_ftr_fixup_test2)
46 globl(ftr_fixup_test2_orig)
51 globl(ftr_fixup_test2_alt)
54 globl(ftr_fixup_test2_expected)
59 globl(ftr_fixup_test3)
61 or 2,2,2 /* fixup will fail to replace this */
64 globl(end_ftr_fixup_test3)
66 globl(ftr_fixup_test3_orig)
71 globl(ftr_fixup_test3_alt)
75 globl(ftr_fixup_test4)
83 globl(end_ftr_fixup_test4)
85 globl(ftr_fixup_test4_expected)
93 globl(ftr_fixup_test4_orig)
101 globl(ftr_fixup_test4_alt)
106 globl(ftr_fixup_test5)
124 ALT_FTR_SECTION_END(0, 1)
127 globl(end_ftr_fixup_test5)
129 globl(ftr_fixup_test5_expected)
140 globl(ftr_fixup_test6)
156 ALT_FTR_SECTION_END(0, 1)
161 globl(end_ftr_fixup_test6)
163 globl(ftr_fixup_test6_expected)
175 globl(ftr_fixup_test7)
194 ALT_FTR_SECTION_END(0, 1)
198 globl(end_ftr_fixup_test7)
201 globl(ftr_fixup_test7_expected)
213 /* Test that if we have a larger else case the assembler spots it and
214 * reports an error. #if 0'ed so as not to break the build normally.
216 ftr_fixup_test_too_big:
227 ALT_FTR_SECTION_END(0, 1)
231 #define MAKE_MACRO_TEST(TYPE) \
232 globl(ftr_fixup_test_ ##TYPE##_macros) \
234 /* Basic test, this section should all be nop'ed */ \
235 BEGIN_##TYPE##_SECTION \
239 END_##TYPE##_SECTION(0, 1) \
242 /* Basic test, this section should NOT be nop'ed */ \
243 BEGIN_##TYPE##_SECTION \
247 END_##TYPE##_SECTION(0, 0) \
250 /* Nesting test, inner section should be nop'ed */ \
251 BEGIN_##TYPE##_SECTION \
254 BEGIN_##TYPE##_SECTION_NESTED(80) \
257 END_##TYPE##_SECTION_NESTED(0, 1, 80) \
260 END_##TYPE##_SECTION(0, 0) \
263 /* Nesting test, whole section should be nop'ed */ \
264 BEGIN_##TYPE##_SECTION \
267 BEGIN_##TYPE##_SECTION_NESTED(80) \
270 END_##TYPE##_SECTION_NESTED(0, 0, 80) \
273 END_##TYPE##_SECTION(0, 1) \
276 /* Nesting test, none should be nop'ed */ \
277 BEGIN_##TYPE##_SECTION \
280 BEGIN_##TYPE##_SECTION_NESTED(80) \
283 END_##TYPE##_SECTION_NESTED(0, 0, 80) \
286 END_##TYPE##_SECTION(0, 0) \
289 /* Basic alt section test, default case should be taken */ \
290 BEGIN_##TYPE##_SECTION \
294 ##TYPE##_SECTION_ELSE \
297 ALT_##TYPE##_SECTION_END(0, 0) \
300 /* Basic alt section test, else case should be taken */ \
301 BEGIN_##TYPE##_SECTION \
305 ##TYPE##_SECTION_ELSE \
309 ALT_##TYPE##_SECTION_END(0, 1) \
312 /* Alt with smaller else case, should be padded with nops */ \
313 BEGIN_##TYPE##_SECTION \
317 ##TYPE##_SECTION_ELSE \
319 ALT_##TYPE##_SECTION_END(0, 1) \
322 /* Alt section with nested section in default case */ \
323 /* Default case should be taken, with nop'ed inner section */ \
324 BEGIN_##TYPE##_SECTION \
326 BEGIN_##TYPE##_SECTION_NESTED(95) \
329 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
331 ##TYPE##_SECTION_ELSE \
334 ALT_##TYPE##_SECTION_END(0, 0) \
337 /* Alt section with nested section in else, default taken */ \
338 BEGIN_##TYPE##_SECTION \
342 ##TYPE##_SECTION_ELSE \
344 BEGIN_##TYPE##_SECTION_NESTED(95) \
346 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
348 ALT_##TYPE##_SECTION_END(0, 0) \
351 /* Alt section with nested section in else, else taken & nop */ \
352 BEGIN_##TYPE##_SECTION \
356 ##TYPE##_SECTION_ELSE \
358 BEGIN_##TYPE##_SECTION_NESTED(95) \
360 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
362 ALT_##TYPE##_SECTION_END(0, 1) \
365 /* Feature section with nested alt section, default taken */ \
366 BEGIN_##TYPE##_SECTION \
368 BEGIN_##TYPE##_SECTION_NESTED(95) \
370 ##TYPE##_SECTION_ELSE_NESTED(95) \
372 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
374 END_##TYPE##_SECTION(0, 0) \
377 /* Feature section with nested alt section, else taken */ \
378 BEGIN_##TYPE##_SECTION \
380 BEGIN_##TYPE##_SECTION_NESTED(95) \
382 ##TYPE##_SECTION_ELSE_NESTED(95) \
384 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
386 END_##TYPE##_SECTION(0, 0) \
389 /* Feature section with nested alt section, all nop'ed */ \
390 BEGIN_##TYPE##_SECTION \
392 BEGIN_##TYPE##_SECTION_NESTED(95) \
394 ##TYPE##_SECTION_ELSE_NESTED(95) \
396 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
398 END_##TYPE##_SECTION(0, 1) \
401 /* Nested alt sections, default with inner default taken */ \
402 BEGIN_##TYPE##_SECTION \
404 BEGIN_##TYPE##_SECTION_NESTED(95) \
406 ##TYPE##_SECTION_ELSE_NESTED(95) \
408 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
410 ##TYPE##_SECTION_ELSE \
412 BEGIN_##TYPE##_SECTION_NESTED(94) \
414 ##TYPE##_SECTION_ELSE_NESTED(94) \
416 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
418 ALT_##TYPE##_SECTION_END(0, 0) \
421 /* Nested alt sections, default with inner else taken */ \
422 BEGIN_##TYPE##_SECTION \
424 BEGIN_##TYPE##_SECTION_NESTED(95) \
426 ##TYPE##_SECTION_ELSE_NESTED(95) \
428 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
430 ##TYPE##_SECTION_ELSE \
432 BEGIN_##TYPE##_SECTION_NESTED(94) \
434 ##TYPE##_SECTION_ELSE_NESTED(94) \
436 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
438 ALT_##TYPE##_SECTION_END(0, 0) \
441 /* Nested alt sections, else with inner default taken */ \
442 BEGIN_##TYPE##_SECTION \
444 BEGIN_##TYPE##_SECTION_NESTED(95) \
446 ##TYPE##_SECTION_ELSE_NESTED(95) \
448 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
450 ##TYPE##_SECTION_ELSE \
452 BEGIN_##TYPE##_SECTION_NESTED(94) \
454 ##TYPE##_SECTION_ELSE_NESTED(94) \
456 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
458 ALT_##TYPE##_SECTION_END(0, 1) \
461 /* Nested alt sections, else with inner else taken */ \
462 BEGIN_##TYPE##_SECTION \
464 BEGIN_##TYPE##_SECTION_NESTED(95) \
466 ##TYPE##_SECTION_ELSE_NESTED(95) \
468 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
470 ##TYPE##_SECTION_ELSE \
472 BEGIN_##TYPE##_SECTION_NESTED(94) \
474 ##TYPE##_SECTION_ELSE_NESTED(94) \
476 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) \
478 ALT_##TYPE##_SECTION_END(0, 1) \
481 /* Nested alt sections, else can have large else case */ \
482 BEGIN_##TYPE##_SECTION \
487 ##TYPE##_SECTION_ELSE \
488 BEGIN_##TYPE##_SECTION_NESTED(94) \
493 ##TYPE##_SECTION_ELSE_NESTED(94) \
498 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) \
499 ALT_##TYPE##_SECTION_END(0, 1) \
503 #define MAKE_MACRO_TEST_EXPECTED(TYPE) \
504 globl(ftr_fixup_test_ ##TYPE##_macros_expected) \
506 /* Basic test, this section should all be nop'ed */ \
507 /* BEGIN_##TYPE##_SECTION */ \
511 /* END_##TYPE##_SECTION(0, 1) */ \
514 /* Basic test, this section should NOT be nop'ed */ \
515 /* BEGIN_##TYPE##_SECTION */ \
519 /* END_##TYPE##_SECTION(0, 0) */ \
522 /* Nesting test, inner section should be nop'ed */ \
523 /* BEGIN_##TYPE##_SECTION */ \
526 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
529 /* END_##TYPE##_SECTION_NESTED(0, 1, 80) */ \
532 /* END_##TYPE##_SECTION(0, 0) */ \
535 /* Nesting test, whole section should be nop'ed */ \
536 /* NB. inner section is not nop'ed, but then entire outer is */ \
537 /* BEGIN_##TYPE##_SECTION */ \
540 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
543 /* END_##TYPE##_SECTION_NESTED(0, 0, 80) */ \
546 /* END_##TYPE##_SECTION(0, 1) */ \
549 /* Nesting test, none should be nop'ed */ \
550 /* BEGIN_##TYPE##_SECTION */ \
553 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
556 /* END_##TYPE##_SECTION_NESTED(0, 0, 80) */ \
559 /* END_##TYPE##_SECTION(0, 0) */ \
562 /* Basic alt section test, default case should be taken */ \
563 /* BEGIN_##TYPE##_SECTION */ \
567 /* ##TYPE##_SECTION_ELSE */ \
570 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
573 /* Basic alt section test, else case should be taken */ \
574 /* BEGIN_##TYPE##_SECTION */ \
578 /* ##TYPE##_SECTION_ELSE */ \
582 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
585 /* Alt with smaller else case, should be padded with nops */ \
586 /* BEGIN_##TYPE##_SECTION */ \
590 /* ##TYPE##_SECTION_ELSE */ \
594 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
597 /* Alt section with nested section in default case */ \
598 /* Default case should be taken, with nop'ed inner section */ \
599 /* BEGIN_##TYPE##_SECTION */ \
601 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
604 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
606 /* ##TYPE##_SECTION_ELSE */ \
609 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
612 /* Alt section with nested section in else, default taken */ \
613 /* BEGIN_##TYPE##_SECTION */ \
617 /* ##TYPE##_SECTION_ELSE */ \
619 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
621 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
623 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
626 /* Alt section with nested section in else, else taken & nop */ \
627 /* BEGIN_##TYPE##_SECTION */ \
631 /* ##TYPE##_SECTION_ELSE */ \
633 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
635 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
637 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
640 /* Feature section with nested alt section, default taken */ \
641 /* BEGIN_##TYPE##_SECTION */ \
643 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
645 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
647 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
649 /* END_##TYPE##_SECTION(0, 0) */ \
652 /* Feature section with nested alt section, else taken */ \
653 /* BEGIN_##TYPE##_SECTION */ \
655 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
657 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
659 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
661 /* END_##TYPE##_SECTION(0, 0) */ \
664 /* Feature section with nested alt section, all nop'ed */ \
665 /* BEGIN_##TYPE##_SECTION */ \
667 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
669 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
671 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
673 /* END_##TYPE##_SECTION(0, 1) */ \
676 /* Nested alt sections, default with inner default taken */ \
677 /* BEGIN_##TYPE##_SECTION */ \
679 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
681 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
683 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
685 /* ##TYPE##_SECTION_ELSE */ \
687 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
689 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
691 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
693 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
696 /* Nested alt sections, default with inner else taken */ \
697 /* BEGIN_##TYPE##_SECTION */ \
699 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
701 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
703 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
705 /* ##TYPE##_SECTION_ELSE */ \
707 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
709 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
711 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
713 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
716 /* Nested alt sections, else with inner default taken */ \
717 /* BEGIN_##TYPE##_SECTION */ \
719 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
721 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
723 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
725 /* ##TYPE##_SECTION_ELSE */ \
727 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
729 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
731 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
733 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
736 /* Nested alt sections, else with inner else taken */ \
737 /* BEGIN_##TYPE##_SECTION */ \
739 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
741 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
743 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
745 /* ##TYPE##_SECTION_ELSE */ \
747 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
749 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
751 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */ \
753 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
756 /* Nested alt sections, else can have large else case */ \
757 /* BEGIN_##TYPE##_SECTION */ \
762 /* ##TYPE##_SECTION_ELSE */ \
763 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
768 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
773 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */ \
774 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
778 MAKE_MACRO_TEST(FTR);
779 MAKE_MACRO_TEST_EXPECTED(FTR);
782 MAKE_MACRO_TEST(FW_FTR);
783 MAKE_MACRO_TEST_EXPECTED(FW_FTR);
786 globl(lwsync_fixup_test)
789 globl(end_lwsync_fixup_test)
791 globl(lwsync_fixup_test_expected_LWSYNC)
795 globl(lwsync_fixup_test_expected_SYNC)