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)
176 /* Test that if we have a larger else case the assembler spots it and
177 * reports an error. #if 0'ed so as not to break the build normally.
190 ALT_FTR_SECTION_END(0, 1)
194 #define MAKE_MACRO_TEST(TYPE) \
195 globl(ftr_fixup_test_ ##TYPE##_macros) \
197 /* Basic test, this section should all be nop'ed */ \
198 BEGIN_##TYPE##_SECTION \
202 END_##TYPE##_SECTION(0, 1) \
205 /* Basic test, this section should NOT be nop'ed */ \
206 BEGIN_##TYPE##_SECTION \
210 END_##TYPE##_SECTION(0, 0) \
213 /* Nesting test, inner section should be nop'ed */ \
214 BEGIN_##TYPE##_SECTION \
217 BEGIN_##TYPE##_SECTION_NESTED(80) \
220 END_##TYPE##_SECTION_NESTED(0, 1, 80) \
223 END_##TYPE##_SECTION(0, 0) \
226 /* Nesting test, whole section should be nop'ed */ \
227 BEGIN_##TYPE##_SECTION \
230 BEGIN_##TYPE##_SECTION_NESTED(80) \
233 END_##TYPE##_SECTION_NESTED(0, 0, 80) \
236 END_##TYPE##_SECTION(0, 1) \
239 /* Nesting test, none should be nop'ed */ \
240 BEGIN_##TYPE##_SECTION \
243 BEGIN_##TYPE##_SECTION_NESTED(80) \
246 END_##TYPE##_SECTION_NESTED(0, 0, 80) \
249 END_##TYPE##_SECTION(0, 0) \
252 /* Basic alt section test, default case should be taken */ \
253 BEGIN_##TYPE##_SECTION \
257 ##TYPE##_SECTION_ELSE \
260 ALT_##TYPE##_SECTION_END(0, 0) \
263 /* Basic alt section test, else case should be taken */ \
264 BEGIN_##TYPE##_SECTION \
268 ##TYPE##_SECTION_ELSE \
272 ALT_##TYPE##_SECTION_END(0, 1) \
275 /* Alt with smaller else case, should be padded with nops */ \
276 BEGIN_##TYPE##_SECTION \
280 ##TYPE##_SECTION_ELSE \
282 ALT_##TYPE##_SECTION_END(0, 1) \
285 /* Alt section with nested section in default case */ \
286 /* Default case should be taken, with nop'ed inner section */ \
287 BEGIN_##TYPE##_SECTION \
289 BEGIN_##TYPE##_SECTION_NESTED(95) \
292 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
294 ##TYPE##_SECTION_ELSE \
297 ALT_##TYPE##_SECTION_END(0, 0) \
300 /* Alt section with nested section in else, default taken */ \
301 BEGIN_##TYPE##_SECTION \
305 ##TYPE##_SECTION_ELSE \
307 BEGIN_##TYPE##_SECTION_NESTED(95) \
309 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
311 ALT_##TYPE##_SECTION_END(0, 0) \
314 /* Alt section with nested section in else, else taken & nop */ \
315 BEGIN_##TYPE##_SECTION \
319 ##TYPE##_SECTION_ELSE \
321 BEGIN_##TYPE##_SECTION_NESTED(95) \
323 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
325 ALT_##TYPE##_SECTION_END(0, 1) \
328 /* Feature section with nested alt section, default taken */ \
329 BEGIN_##TYPE##_SECTION \
331 BEGIN_##TYPE##_SECTION_NESTED(95) \
333 ##TYPE##_SECTION_ELSE_NESTED(95) \
335 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
337 END_##TYPE##_SECTION(0, 0) \
340 /* Feature section with nested alt section, else taken */ \
341 BEGIN_##TYPE##_SECTION \
343 BEGIN_##TYPE##_SECTION_NESTED(95) \
345 ##TYPE##_SECTION_ELSE_NESTED(95) \
347 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
349 END_##TYPE##_SECTION(0, 0) \
352 /* Feature section with nested alt section, all nop'ed */ \
353 BEGIN_##TYPE##_SECTION \
355 BEGIN_##TYPE##_SECTION_NESTED(95) \
357 ##TYPE##_SECTION_ELSE_NESTED(95) \
359 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
361 END_##TYPE##_SECTION(0, 1) \
364 /* Nested alt sections, default with inner default taken */ \
365 BEGIN_##TYPE##_SECTION \
367 BEGIN_##TYPE##_SECTION_NESTED(95) \
369 ##TYPE##_SECTION_ELSE_NESTED(95) \
371 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
373 ##TYPE##_SECTION_ELSE \
375 BEGIN_##TYPE##_SECTION_NESTED(94) \
377 ##TYPE##_SECTION_ELSE_NESTED(94) \
379 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
381 ALT_##TYPE##_SECTION_END(0, 0) \
384 /* Nested alt sections, default with inner else taken */ \
385 BEGIN_##TYPE##_SECTION \
387 BEGIN_##TYPE##_SECTION_NESTED(95) \
389 ##TYPE##_SECTION_ELSE_NESTED(95) \
391 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
393 ##TYPE##_SECTION_ELSE \
395 BEGIN_##TYPE##_SECTION_NESTED(94) \
397 ##TYPE##_SECTION_ELSE_NESTED(94) \
399 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
401 ALT_##TYPE##_SECTION_END(0, 0) \
404 /* Nested alt sections, else with inner default taken */ \
405 BEGIN_##TYPE##_SECTION \
407 BEGIN_##TYPE##_SECTION_NESTED(95) \
409 ##TYPE##_SECTION_ELSE_NESTED(95) \
411 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
413 ##TYPE##_SECTION_ELSE \
415 BEGIN_##TYPE##_SECTION_NESTED(94) \
417 ##TYPE##_SECTION_ELSE_NESTED(94) \
419 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
421 ALT_##TYPE##_SECTION_END(0, 1) \
424 /* Nested alt sections, else with inner else taken */ \
425 BEGIN_##TYPE##_SECTION \
427 BEGIN_##TYPE##_SECTION_NESTED(95) \
429 ##TYPE##_SECTION_ELSE_NESTED(95) \
431 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
433 ##TYPE##_SECTION_ELSE \
435 BEGIN_##TYPE##_SECTION_NESTED(94) \
437 ##TYPE##_SECTION_ELSE_NESTED(94) \
439 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) \
441 ALT_##TYPE##_SECTION_END(0, 1) \
444 /* Nested alt sections, else can have large else case */ \
445 BEGIN_##TYPE##_SECTION \
450 ##TYPE##_SECTION_ELSE \
451 BEGIN_##TYPE##_SECTION_NESTED(94) \
456 ##TYPE##_SECTION_ELSE_NESTED(94) \
461 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) \
462 ALT_##TYPE##_SECTION_END(0, 1) \
466 #define MAKE_MACRO_TEST_EXPECTED(TYPE) \
467 globl(ftr_fixup_test_ ##TYPE##_macros_expected) \
469 /* Basic test, this section should all be nop'ed */ \
470 /* BEGIN_##TYPE##_SECTION */ \
474 /* END_##TYPE##_SECTION(0, 1) */ \
477 /* Basic test, this section should NOT be nop'ed */ \
478 /* BEGIN_##TYPE##_SECTION */ \
482 /* END_##TYPE##_SECTION(0, 0) */ \
485 /* Nesting test, inner section should be nop'ed */ \
486 /* BEGIN_##TYPE##_SECTION */ \
489 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
492 /* END_##TYPE##_SECTION_NESTED(0, 1, 80) */ \
495 /* END_##TYPE##_SECTION(0, 0) */ \
498 /* Nesting test, whole section should be nop'ed */ \
499 /* NB. inner section is not nop'ed, but then entire outer is */ \
500 /* BEGIN_##TYPE##_SECTION */ \
503 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
506 /* END_##TYPE##_SECTION_NESTED(0, 0, 80) */ \
509 /* END_##TYPE##_SECTION(0, 1) */ \
512 /* Nesting test, none should be nop'ed */ \
513 /* BEGIN_##TYPE##_SECTION */ \
516 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
519 /* END_##TYPE##_SECTION_NESTED(0, 0, 80) */ \
522 /* END_##TYPE##_SECTION(0, 0) */ \
525 /* Basic alt section test, default case should be taken */ \
526 /* BEGIN_##TYPE##_SECTION */ \
530 /* ##TYPE##_SECTION_ELSE */ \
533 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
536 /* Basic alt section test, else case should be taken */ \
537 /* BEGIN_##TYPE##_SECTION */ \
541 /* ##TYPE##_SECTION_ELSE */ \
545 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
548 /* Alt with smaller else case, should be padded with nops */ \
549 /* BEGIN_##TYPE##_SECTION */ \
553 /* ##TYPE##_SECTION_ELSE */ \
557 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
560 /* Alt section with nested section in default case */ \
561 /* Default case should be taken, with nop'ed inner section */ \
562 /* BEGIN_##TYPE##_SECTION */ \
564 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
567 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
569 /* ##TYPE##_SECTION_ELSE */ \
572 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
575 /* Alt section with nested section in else, default taken */ \
576 /* BEGIN_##TYPE##_SECTION */ \
580 /* ##TYPE##_SECTION_ELSE */ \
582 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
584 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
586 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
589 /* Alt section with nested section in else, else taken & nop */ \
590 /* BEGIN_##TYPE##_SECTION */ \
594 /* ##TYPE##_SECTION_ELSE */ \
596 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
598 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
600 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
603 /* Feature section with nested alt section, default taken */ \
604 /* BEGIN_##TYPE##_SECTION */ \
606 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
608 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
610 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
612 /* END_##TYPE##_SECTION(0, 0) */ \
615 /* Feature section with nested alt section, else taken */ \
616 /* BEGIN_##TYPE##_SECTION */ \
618 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
620 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
622 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
624 /* END_##TYPE##_SECTION(0, 0) */ \
627 /* Feature section with nested alt section, all nop'ed */ \
628 /* BEGIN_##TYPE##_SECTION */ \
630 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
632 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
634 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
636 /* END_##TYPE##_SECTION(0, 1) */ \
639 /* Nested alt sections, default with inner default taken */ \
640 /* BEGIN_##TYPE##_SECTION */ \
642 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
644 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
646 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
648 /* ##TYPE##_SECTION_ELSE */ \
650 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
652 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
654 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
656 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
659 /* Nested alt sections, default with inner else taken */ \
660 /* BEGIN_##TYPE##_SECTION */ \
662 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
664 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
666 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
668 /* ##TYPE##_SECTION_ELSE */ \
670 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
672 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
674 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
676 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
679 /* Nested alt sections, else with inner default taken */ \
680 /* BEGIN_##TYPE##_SECTION */ \
682 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
684 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
686 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
688 /* ##TYPE##_SECTION_ELSE */ \
690 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
692 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
694 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
696 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
699 /* Nested alt sections, else with inner else taken */ \
700 /* BEGIN_##TYPE##_SECTION */ \
702 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
704 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
706 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
708 /* ##TYPE##_SECTION_ELSE */ \
710 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
712 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
714 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */ \
716 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
719 /* Nested alt sections, else can have large else case */ \
720 /* BEGIN_##TYPE##_SECTION */ \
725 /* ##TYPE##_SECTION_ELSE */ \
726 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
731 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
736 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */ \
737 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
741 MAKE_MACRO_TEST(FTR);
742 MAKE_MACRO_TEST_EXPECTED(FTR);
745 MAKE_MACRO_TEST(FW_FTR);
746 MAKE_MACRO_TEST_EXPECTED(FW_FTR);
749 globl(lwsync_fixup_test)
752 globl(end_lwsync_fixup_test)
754 globl(lwsync_fixup_test_expected_LWSYNC)
758 globl(lwsync_fixup_test_expected_SYNC)