diff options
Diffstat (limited to 'include/asm-alpha/system.h')
-rw-r--r-- | include/asm-alpha/system.h | 226 |
1 files changed, 225 insertions, 1 deletions
diff --git a/include/asm-alpha/system.h b/include/asm-alpha/system.h index 03e9c0e5ed74..cf1021a97b2e 100644 --- a/include/asm-alpha/system.h +++ b/include/asm-alpha/system.h | |||
@@ -443,8 +443,110 @@ extern void __xchg_called_with_bad_pointer(void); | |||
443 | (__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, sizeof(*(ptr))); \ | 443 | (__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, sizeof(*(ptr))); \ |
444 | }) | 444 | }) |
445 | 445 | ||
446 | #define tas(ptr) (xchg((ptr),1)) | 446 | static inline unsigned long |
447 | __xchg_u8_local(volatile char *m, unsigned long val) | ||
448 | { | ||
449 | unsigned long ret, tmp, addr64; | ||
450 | |||
451 | __asm__ __volatile__( | ||
452 | " andnot %4,7,%3\n" | ||
453 | " insbl %1,%4,%1\n" | ||
454 | "1: ldq_l %2,0(%3)\n" | ||
455 | " extbl %2,%4,%0\n" | ||
456 | " mskbl %2,%4,%2\n" | ||
457 | " or %1,%2,%2\n" | ||
458 | " stq_c %2,0(%3)\n" | ||
459 | " beq %2,2f\n" | ||
460 | ".subsection 2\n" | ||
461 | "2: br 1b\n" | ||
462 | ".previous" | ||
463 | : "=&r" (ret), "=&r" (val), "=&r" (tmp), "=&r" (addr64) | ||
464 | : "r" ((long)m), "1" (val) : "memory"); | ||
447 | 465 | ||
466 | return ret; | ||
467 | } | ||
468 | |||
469 | static inline unsigned long | ||
470 | __xchg_u16_local(volatile short *m, unsigned long val) | ||
471 | { | ||
472 | unsigned long ret, tmp, addr64; | ||
473 | |||
474 | __asm__ __volatile__( | ||
475 | " andnot %4,7,%3\n" | ||
476 | " inswl %1,%4,%1\n" | ||
477 | "1: ldq_l %2,0(%3)\n" | ||
478 | " extwl %2,%4,%0\n" | ||
479 | " mskwl %2,%4,%2\n" | ||
480 | " or %1,%2,%2\n" | ||
481 | " stq_c %2,0(%3)\n" | ||
482 | " beq %2,2f\n" | ||
483 | ".subsection 2\n" | ||
484 | "2: br 1b\n" | ||
485 | ".previous" | ||
486 | : "=&r" (ret), "=&r" (val), "=&r" (tmp), "=&r" (addr64) | ||
487 | : "r" ((long)m), "1" (val) : "memory"); | ||
488 | |||
489 | return ret; | ||
490 | } | ||
491 | |||
492 | static inline unsigned long | ||
493 | __xchg_u32_local(volatile int *m, unsigned long val) | ||
494 | { | ||
495 | unsigned long dummy; | ||
496 | |||
497 | __asm__ __volatile__( | ||
498 | "1: ldl_l %0,%4\n" | ||
499 | " bis $31,%3,%1\n" | ||
500 | " stl_c %1,%2\n" | ||
501 | " beq %1,2f\n" | ||
502 | ".subsection 2\n" | ||
503 | "2: br 1b\n" | ||
504 | ".previous" | ||
505 | : "=&r" (val), "=&r" (dummy), "=m" (*m) | ||
506 | : "rI" (val), "m" (*m) : "memory"); | ||
507 | |||
508 | return val; | ||
509 | } | ||
510 | |||
511 | static inline unsigned long | ||
512 | __xchg_u64_local(volatile long *m, unsigned long val) | ||
513 | { | ||
514 | unsigned long dummy; | ||
515 | |||
516 | __asm__ __volatile__( | ||
517 | "1: ldq_l %0,%4\n" | ||
518 | " bis $31,%3,%1\n" | ||
519 | " stq_c %1,%2\n" | ||
520 | " beq %1,2f\n" | ||
521 | ".subsection 2\n" | ||
522 | "2: br 1b\n" | ||
523 | ".previous" | ||
524 | : "=&r" (val), "=&r" (dummy), "=m" (*m) | ||
525 | : "rI" (val), "m" (*m) : "memory"); | ||
526 | |||
527 | return val; | ||
528 | } | ||
529 | |||
530 | #define __xchg_local(ptr, x, size) \ | ||
531 | ({ \ | ||
532 | unsigned long __xchg__res; \ | ||
533 | volatile void *__xchg__ptr = (ptr); \ | ||
534 | switch (size) { \ | ||
535 | case 1: __xchg__res = __xchg_u8_local(__xchg__ptr, x); break; \ | ||
536 | case 2: __xchg__res = __xchg_u16_local(__xchg__ptr, x); break; \ | ||
537 | case 4: __xchg__res = __xchg_u32_local(__xchg__ptr, x); break; \ | ||
538 | case 8: __xchg__res = __xchg_u64_local(__xchg__ptr, x); break; \ | ||
539 | default: __xchg_called_with_bad_pointer(); __xchg__res = x; \ | ||
540 | } \ | ||
541 | __xchg__res; \ | ||
542 | }) | ||
543 | |||
544 | #define xchg_local(ptr,x) \ | ||
545 | ({ \ | ||
546 | __typeof__(*(ptr)) _x_ = (x); \ | ||
547 | (__typeof__(*(ptr))) __xchg_local((ptr), (unsigned long)_x_, \ | ||
548 | sizeof(*(ptr))); \ | ||
549 | }) | ||
448 | 550 | ||
449 | /* | 551 | /* |
450 | * Atomic compare and exchange. Compare OLD with MEM, if identical, | 552 | * Atomic compare and exchange. Compare OLD with MEM, if identical, |
@@ -596,6 +698,128 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) | |||
596 | (unsigned long)_n_, sizeof(*(ptr))); \ | 698 | (unsigned long)_n_, sizeof(*(ptr))); \ |
597 | }) | 699 | }) |
598 | 700 | ||
701 | static inline unsigned long | ||
702 | __cmpxchg_u8_local(volatile char *m, long old, long new) | ||
703 | { | ||
704 | unsigned long prev, tmp, cmp, addr64; | ||
705 | |||
706 | __asm__ __volatile__( | ||
707 | " andnot %5,7,%4\n" | ||
708 | " insbl %1,%5,%1\n" | ||
709 | "1: ldq_l %2,0(%4)\n" | ||
710 | " extbl %2,%5,%0\n" | ||
711 | " cmpeq %0,%6,%3\n" | ||
712 | " beq %3,2f\n" | ||
713 | " mskbl %2,%5,%2\n" | ||
714 | " or %1,%2,%2\n" | ||
715 | " stq_c %2,0(%4)\n" | ||
716 | " beq %2,3f\n" | ||
717 | "2:\n" | ||
718 | ".subsection 2\n" | ||
719 | "3: br 1b\n" | ||
720 | ".previous" | ||
721 | : "=&r" (prev), "=&r" (new), "=&r" (tmp), "=&r" (cmp), "=&r" (addr64) | ||
722 | : "r" ((long)m), "Ir" (old), "1" (new) : "memory"); | ||
723 | |||
724 | return prev; | ||
725 | } | ||
726 | |||
727 | static inline unsigned long | ||
728 | __cmpxchg_u16_local(volatile short *m, long old, long new) | ||
729 | { | ||
730 | unsigned long prev, tmp, cmp, addr64; | ||
731 | |||
732 | __asm__ __volatile__( | ||
733 | " andnot %5,7,%4\n" | ||
734 | " inswl %1,%5,%1\n" | ||
735 | "1: ldq_l %2,0(%4)\n" | ||
736 | " extwl %2,%5,%0\n" | ||
737 | " cmpeq %0,%6,%3\n" | ||
738 | " beq %3,2f\n" | ||
739 | " mskwl %2,%5,%2\n" | ||
740 | " or %1,%2,%2\n" | ||
741 | " stq_c %2,0(%4)\n" | ||
742 | " beq %2,3f\n" | ||
743 | "2:\n" | ||
744 | ".subsection 2\n" | ||
745 | "3: br 1b\n" | ||
746 | ".previous" | ||
747 | : "=&r" (prev), "=&r" (new), "=&r" (tmp), "=&r" (cmp), "=&r" (addr64) | ||
748 | : "r" ((long)m), "Ir" (old), "1" (new) : "memory"); | ||
749 | |||
750 | return prev; | ||
751 | } | ||
752 | |||
753 | static inline unsigned long | ||
754 | __cmpxchg_u32_local(volatile int *m, int old, int new) | ||
755 | { | ||
756 | unsigned long prev, cmp; | ||
757 | |||
758 | __asm__ __volatile__( | ||
759 | "1: ldl_l %0,%5\n" | ||
760 | " cmpeq %0,%3,%1\n" | ||
761 | " beq %1,2f\n" | ||
762 | " mov %4,%1\n" | ||
763 | " stl_c %1,%2\n" | ||
764 | " beq %1,3f\n" | ||
765 | "2:\n" | ||
766 | ".subsection 2\n" | ||
767 | "3: br 1b\n" | ||
768 | ".previous" | ||
769 | : "=&r"(prev), "=&r"(cmp), "=m"(*m) | ||
770 | : "r"((long) old), "r"(new), "m"(*m) : "memory"); | ||
771 | |||
772 | return prev; | ||
773 | } | ||
774 | |||
775 | static inline unsigned long | ||
776 | __cmpxchg_u64_local(volatile long *m, unsigned long old, unsigned long new) | ||
777 | { | ||
778 | unsigned long prev, cmp; | ||
779 | |||
780 | __asm__ __volatile__( | ||
781 | "1: ldq_l %0,%5\n" | ||
782 | " cmpeq %0,%3,%1\n" | ||
783 | " beq %1,2f\n" | ||
784 | " mov %4,%1\n" | ||
785 | " stq_c %1,%2\n" | ||
786 | " beq %1,3f\n" | ||
787 | "2:\n" | ||
788 | ".subsection 2\n" | ||
789 | "3: br 1b\n" | ||
790 | ".previous" | ||
791 | : "=&r"(prev), "=&r"(cmp), "=m"(*m) | ||
792 | : "r"((long) old), "r"(new), "m"(*m) : "memory"); | ||
793 | |||
794 | return prev; | ||
795 | } | ||
796 | |||
797 | static __always_inline unsigned long | ||
798 | __cmpxchg_local(volatile void *ptr, unsigned long old, unsigned long new, | ||
799 | int size) | ||
800 | { | ||
801 | switch (size) { | ||
802 | case 1: | ||
803 | return __cmpxchg_u8_local(ptr, old, new); | ||
804 | case 2: | ||
805 | return __cmpxchg_u16_local(ptr, old, new); | ||
806 | case 4: | ||
807 | return __cmpxchg_u32_local(ptr, old, new); | ||
808 | case 8: | ||
809 | return __cmpxchg_u64_local(ptr, old, new); | ||
810 | } | ||
811 | __cmpxchg_called_with_bad_pointer(); | ||
812 | return old; | ||
813 | } | ||
814 | |||
815 | #define cmpxchg_local(ptr,o,n) \ | ||
816 | ({ \ | ||
817 | __typeof__(*(ptr)) _o_ = (o); \ | ||
818 | __typeof__(*(ptr)) _n_ = (n); \ | ||
819 | (__typeof__(*(ptr))) __cmpxchg_local((ptr), (unsigned long)_o_, \ | ||
820 | (unsigned long)_n_, sizeof(*(ptr))); \ | ||
821 | }) | ||
822 | |||
599 | #endif /* __ASSEMBLY__ */ | 823 | #endif /* __ASSEMBLY__ */ |
600 | 824 | ||
601 | #define arch_align_stack(x) (x) | 825 | #define arch_align_stack(x) (x) |