aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mn10300/mm/misalignment.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-11-12 10:35:04 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-11-12 13:41:17 -0500
commit9f55588968095306d52bd30564666d4fadce5e39 (patch)
treed75a97919e847f4dcdee8d6b75d6f06f2688f235 /arch/mn10300/mm/misalignment.c
parent31ea24bba77a16d3220b0822838785cbafb78175 (diff)
MN10300: Add built-in testing for misalignment handler
Add configurable built-in testing for the MN10300 misalignment handler. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/mn10300/mm/misalignment.c')
-rw-r--r--arch/mn10300/mm/misalignment.c161
1 files changed, 161 insertions, 0 deletions
diff --git a/arch/mn10300/mm/misalignment.c b/arch/mn10300/mm/misalignment.c
index 416c43baaa21..93e09c4be1db 100644
--- a/arch/mn10300/mm/misalignment.c
+++ b/arch/mn10300/mm/misalignment.c
@@ -650,3 +650,164 @@ static int misalignment_reg(unsigned long *registers, unsigned params,
650 650
651 return 1; 651 return 1;
652} 652}
653
654/*
655 * misalignment handler tests
656 */
657#ifdef CONFIG_TEST_MISALIGNMENT_HANDLER
658static u8 __initdata testbuf[512] __attribute__((aligned(16))) = {
659 [257] = 0x11,
660 [258] = 0x22,
661 [259] = 0x33,
662 [260] = 0x44,
663};
664
665#define ASSERTCMP(X, OP, Y) \
666do { \
667 if (unlikely(!((X) OP (Y)))) { \
668 printk(KERN_ERR "\n"); \
669 printk(KERN_ERR "MISALIGN: Assertion failed at line %u\n", \
670 __LINE__); \
671 printk(KERN_ERR "0x%lx " #OP " 0x%lx is false\n", \
672 (unsigned long)(X), (unsigned long)(Y)); \
673 BUG(); \
674 } \
675} while(0)
676
677static int __init test_misalignment(void)
678{
679 register void *r asm("e0");
680 register u32 y asm("e1");
681 void *p = testbuf, *q;
682 u32 tmp, tmp2, x;
683
684 printk(KERN_NOTICE "==>test_misalignment() [testbuf=%p]\n", p);
685 p++;
686
687 printk(KERN_NOTICE "___ MOV (Am),Dn ___\n");
688 q = p + 256;
689 asm volatile("mov (%0),%1" : "+a"(q), "=d"(x));
690 ASSERTCMP(q, ==, p + 256);
691 ASSERTCMP(x, ==, 0x44332211);
692
693 printk(KERN_NOTICE "___ MOV (256,Am),Dn ___\n");
694 q = p;
695 asm volatile("mov (256,%0),%1" : "+a"(q), "=d"(x));
696 ASSERTCMP(q, ==, p);
697 ASSERTCMP(x, ==, 0x44332211);
698
699 printk(KERN_NOTICE "___ MOV (Di,Am),Dn ___\n");
700 tmp = 256;
701 q = p;
702 asm volatile("mov (%2,%0),%1" : "+a"(q), "=d"(x), "+d"(tmp));
703 ASSERTCMP(q, ==, p);
704 ASSERTCMP(x, ==, 0x44332211);
705 ASSERTCMP(tmp, ==, 256);
706
707 printk(KERN_NOTICE "___ MOV (256,Rm),Rn ___\n");
708 r = p;
709 asm volatile("mov (256,%0),%1" : "+r"(r), "=r"(y));
710 ASSERTCMP(r, ==, p);
711 ASSERTCMP(y, ==, 0x44332211);
712
713 printk(KERN_NOTICE "___ MOV (Rm+),Rn ___\n");
714 r = p + 256;
715 asm volatile("mov (%0+),%1" : "+r"(r), "=r"(y));
716 ASSERTCMP(r, ==, p + 256 + 4);
717 ASSERTCMP(y, ==, 0x44332211);
718
719 printk(KERN_NOTICE "___ MOV (Rm+,8),Rn ___\n");
720 r = p + 256;
721 asm volatile("mov (%0+,8),%1" : "+r"(r), "=r"(y));
722 ASSERTCMP(r, ==, p + 256 + 8);
723 ASSERTCMP(y, ==, 0x44332211);
724
725 printk(KERN_NOTICE "___ MOV (7,SP),Rn ___\n");
726 asm volatile(
727 "add -16,sp \n"
728 "mov +0x11,%0 \n"
729 "movbu %0,(7,sp) \n"
730 "mov +0x22,%0 \n"
731 "movbu %0,(8,sp) \n"
732 "mov +0x33,%0 \n"
733 "movbu %0,(9,sp) \n"
734 "mov +0x44,%0 \n"
735 "movbu %0,(10,sp) \n"
736 "mov (7,sp),%1 \n"
737 "add +16,sp \n"
738 : "+a"(q), "=d"(x));
739 ASSERTCMP(x, ==, 0x44332211);
740
741 printk(KERN_NOTICE "___ MOV (259,SP),Rn ___\n");
742 asm volatile(
743 "add -264,sp \n"
744 "mov +0x11,%0 \n"
745 "movbu %0,(259,sp) \n"
746 "mov +0x22,%0 \n"
747 "movbu %0,(260,sp) \n"
748 "mov +0x33,%0 \n"
749 "movbu %0,(261,sp) \n"
750 "mov +0x55,%0 \n"
751 "movbu %0,(262,sp) \n"
752 "mov (259,sp),%1 \n"
753 "add +264,sp \n"
754 : "+d"(tmp), "=d"(x));
755 ASSERTCMP(x, ==, 0x55332211);
756
757 printk(KERN_NOTICE "___ MOV (260,SP),Rn ___\n");
758 asm volatile(
759 "add -264,sp \n"
760 "mov +0x11,%0 \n"
761 "movbu %0,(260,sp) \n"
762 "mov +0x22,%0 \n"
763 "movbu %0,(261,sp) \n"
764 "mov +0x33,%0 \n"
765 "movbu %0,(262,sp) \n"
766 "mov +0x55,%0 \n"
767 "movbu %0,(263,sp) \n"
768 "mov (260,sp),%1 \n"
769 "add +264,sp \n"
770 : "+d"(tmp), "=d"(x));
771 ASSERTCMP(x, ==, 0x55332211);
772
773
774 printk(KERN_NOTICE "___ MOV_LNE ___\n");
775 tmp = 1;
776 tmp2 = 2;
777 q = p + 256;
778 asm volatile(
779 "setlb \n"
780 "mov %2,%3 \n"
781 "mov %1,%2 \n"
782 "cmp +0,%1 \n"
783 "mov_lne (%0+,4),%1"
784 : "+r"(q), "+d"(tmp), "+d"(tmp2), "=d"(x)
785 :
786 : "cc");
787 ASSERTCMP(q, ==, p + 256 + 12);
788 ASSERTCMP(x, ==, 0x44332211);
789
790 printk(KERN_NOTICE "___ MOV in SETLB ___\n");
791 tmp = 1;
792 tmp2 = 2;
793 q = p + 256;
794 asm volatile(
795 "setlb \n"
796 "mov %1,%3 \n"
797 "mov (%0+),%1 \n"
798 "cmp +0,%1 \n"
799 "lne "
800 : "+a"(q), "+d"(tmp), "+d"(tmp2), "=d"(x)
801 :
802 : "cc");
803
804 ASSERTCMP(q, ==, p + 256 + 8);
805 ASSERTCMP(x, ==, 0x44332211);
806
807 printk(KERN_NOTICE "<==test_misalignment()\n");
808 return 0;
809}
810
811arch_initcall(test_misalignment);
812
813#endif /* CONFIG_TEST_MISALIGNMENT_HANDLER */