18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  Copyright (C) 2011 Texas Instruments Incorporated
48c2ecf20Sopenharmony_ci *  Author: Mark Salter <msalter@redhat.com>
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci *  This program is free software; you can redistribute it and/or modify
78c2ecf20Sopenharmony_ci *  it under the terms of the GNU General Public License version 2 as
88c2ecf20Sopenharmony_ci *  published by the Free Software Foundation.
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci#ifndef _ASM_C6X_SWAB_H
118c2ecf20Sopenharmony_ci#define _ASM_C6X_SWAB_H
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_cistatic inline __attribute_const__ __u16 __c6x_swab16(__u16 val)
148c2ecf20Sopenharmony_ci{
158c2ecf20Sopenharmony_ci	asm("swap4 .l1 %0,%0\n" : "+a"(val));
168c2ecf20Sopenharmony_ci	return val;
178c2ecf20Sopenharmony_ci}
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_cistatic inline __attribute_const__ __u32 __c6x_swab32(__u32 val)
208c2ecf20Sopenharmony_ci{
218c2ecf20Sopenharmony_ci	asm("swap4 .l1 %0,%0\n"
228c2ecf20Sopenharmony_ci	    "swap2 .l1 %0,%0\n"
238c2ecf20Sopenharmony_ci	    : "+a"(val));
248c2ecf20Sopenharmony_ci	return val;
258c2ecf20Sopenharmony_ci}
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_cistatic inline __attribute_const__ __u64 __c6x_swab64(__u64 val)
288c2ecf20Sopenharmony_ci{
298c2ecf20Sopenharmony_ci	asm("   swap2 .s1 %p0,%P0\n"
308c2ecf20Sopenharmony_ci	    "|| swap2 .l1 %P0,%p0\n"
318c2ecf20Sopenharmony_ci	    "   swap4 .l1 %p0,%p0\n"
328c2ecf20Sopenharmony_ci	    "   swap4 .l1 %P0,%P0\n"
338c2ecf20Sopenharmony_ci	    : "+a"(val));
348c2ecf20Sopenharmony_ci	return val;
358c2ecf20Sopenharmony_ci}
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_cistatic inline __attribute_const__ __u32 __c6x_swahw32(__u32 val)
388c2ecf20Sopenharmony_ci{
398c2ecf20Sopenharmony_ci	asm("swap2 .l1 %0,%0\n" : "+a"(val));
408c2ecf20Sopenharmony_ci	return val;
418c2ecf20Sopenharmony_ci}
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_cistatic inline __attribute_const__ __u32 __c6x_swahb32(__u32 val)
448c2ecf20Sopenharmony_ci{
458c2ecf20Sopenharmony_ci	asm("swap4 .l1 %0,%0\n" : "+a"(val));
468c2ecf20Sopenharmony_ci	return val;
478c2ecf20Sopenharmony_ci}
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#define __arch_swab16 __c6x_swab16
508c2ecf20Sopenharmony_ci#define __arch_swab32 __c6x_swab32
518c2ecf20Sopenharmony_ci#define __arch_swab64 __c6x_swab64
528c2ecf20Sopenharmony_ci#define __arch_swahw32 __c6x_swahw32
538c2ecf20Sopenharmony_ci#define __arch_swahb32 __c6x_swahb32
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#endif /* _ASM_C6X_SWAB_H */
56