]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/asm-mips/byteorder.h
[PATCH] Enable mprotect on huge pages
[mirror_ubuntu-bionic-kernel.git] / include / asm-mips / byteorder.h
CommitLineData
1da177e4
LT
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 99, 2003 by Ralf Baechle
7 */
8#ifndef _ASM_BYTEORDER_H
9#define _ASM_BYTEORDER_H
10
1e32ceec
RB
11#include <linux/config.h>
12#include <linux/compiler.h>
1da177e4
LT
13#include <asm/types.h>
14
15#ifdef __GNUC__
16
1e32ceec
RB
17#ifdef CONFIG_CPU_MIPSR2
18
19static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x)
20{
21 __asm__(
22 " wsbh %0, %1 \n"
23 : "=r" (x)
24 : "r" (x));
25
26 return x;
27}
28#define __arch__swab16(x) ___arch__swab16(x)
29
30static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
31{
32 __asm__(
33 " wsbh %0, %1 \n"
34 " rotr %0, %0, 16 \n"
35 : "=r" (x)
36 : "r" (x));
37
38 return x;
39}
40#define __arch__swab32(x) ___arch__swab32(x)
41
bbad8123
RB
42#ifdef CONFIG_CPU_MIPS64_R2
43
44static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x)
45{
46 __asm__(
47 " dsbh %0, %1 \n"
48 " dshd %0, %0 \n"
49 " drotr %0, %0, 32 \n"
50 : "=r" (x)
51 : "r" (x));
52
53 return x;
54}
55
56#define __arch__swab64(x) ___arch__swab64(x)
57
58#endif /* CONFIG_CPU_MIPS64_R2 */
59
1e32ceec
RB
60#endif /* CONFIG_CPU_MIPSR2 */
61
1da177e4
LT
62#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
63# define __BYTEORDER_HAS_U64__
64# define __SWAB_64_THRU_32__
65#endif
66
67#endif /* __GNUC__ */
68
69#if defined (__MIPSEB__)
70# include <linux/byteorder/big_endian.h>
71#elif defined (__MIPSEL__)
72# include <linux/byteorder/little_endian.h>
73#else
74# error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???"
75#endif
76
77#endif /* _ASM_BYTEORDER_H */