swab.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; either version
  5. * 2 of the License, or (at your option) any later version.
  6. */
  7. #ifndef _ASM_POWERPC_SWAB_H
  8. #define _ASM_POWERPC_SWAB_H
  9. #include <uapi/asm/swab.h>
  10. static __inline__ __u16 ld_le16(const volatile __u16 *addr)
  11. {
  12. __u16 val;
  13. __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
  14. return val;
  15. }
  16. static __inline__ void st_le16(volatile __u16 *addr, const __u16 val)
  17. {
  18. __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
  19. }
  20. static __inline__ __u32 ld_le32(const volatile __u32 *addr)
  21. {
  22. __u32 val;
  23. __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
  24. return val;
  25. }
  26. static __inline__ void st_le32(volatile __u32 *addr, const __u32 val)
  27. {
  28. __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
  29. }
  30. #endif /* _ASM_POWERPC_SWAB_H */