diff options
author | Ley Foon Tan <lftan@altera.com> | 2014-11-06 02:20:09 -0500 |
---|---|---|
committer | Ley Foon Tan <lftan@altera.com> | 2014-12-07 23:56:03 -0500 |
commit | 97da0d62d4eafe820a85d89da1457d6fad7f0afe (patch) | |
tree | 5a3e7d05bda387a0a1e97a58c1ef1ac03037a63a | |
parent | 2612b87959db46ab9339b395e0ae2a8c9a2a49f6 (diff) |
nios2: Miscellaneous header files
This patch introduces a few nios2-specific header files.
Signed-off-by: Ley Foon Tan <lftan@altera.com>
-rw-r--r-- | arch/nios2/include/asm/cmpxchg.h | 61 | ||||
-rw-r--r-- | arch/nios2/include/asm/linkage.h | 25 | ||||
-rw-r--r-- | arch/nios2/include/asm/mutex.h | 1 | ||||
-rw-r--r-- | arch/nios2/include/uapi/asm/byteorder.h | 22 | ||||
-rw-r--r-- | arch/nios2/include/uapi/asm/swab.h | 37 |
5 files changed, 146 insertions, 0 deletions
diff --git a/arch/nios2/include/asm/cmpxchg.h b/arch/nios2/include/asm/cmpxchg.h new file mode 100644 index 000000000000..85938711542d --- /dev/null +++ b/arch/nios2/include/asm/cmpxchg.h | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004 Microtronix Datacom Ltd. | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | */ | ||
8 | |||
9 | #ifndef _ASM_NIOS2_CMPXCHG_H | ||
10 | #define _ASM_NIOS2_CMPXCHG_H | ||
11 | |||
12 | #include <linux/irqflags.h> | ||
13 | |||
14 | #define xchg(ptr, x) \ | ||
15 | ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr)))) | ||
16 | |||
17 | struct __xchg_dummy { unsigned long a[100]; }; | ||
18 | #define __xg(x) ((volatile struct __xchg_dummy *)(x)) | ||
19 | |||
20 | static inline unsigned long __xchg(unsigned long x, volatile void *ptr, | ||
21 | int size) | ||
22 | { | ||
23 | unsigned long tmp, flags; | ||
24 | |||
25 | local_irq_save(flags); | ||
26 | |||
27 | switch (size) { | ||
28 | case 1: | ||
29 | __asm__ __volatile__( | ||
30 | "ldb %0, %2\n" | ||
31 | "stb %1, %2\n" | ||
32 | : "=&r" (tmp) | ||
33 | : "r" (x), "m" (*__xg(ptr)) | ||
34 | : "memory"); | ||
35 | break; | ||
36 | case 2: | ||
37 | __asm__ __volatile__( | ||
38 | "ldh %0, %2\n" | ||
39 | "sth %1, %2\n" | ||
40 | : "=&r" (tmp) | ||
41 | : "r" (x), "m" (*__xg(ptr)) | ||
42 | : "memory"); | ||
43 | break; | ||
44 | case 4: | ||
45 | __asm__ __volatile__( | ||
46 | "ldw %0, %2\n" | ||
47 | "stw %1, %2\n" | ||
48 | : "=&r" (tmp) | ||
49 | : "r" (x), "m" (*__xg(ptr)) | ||
50 | : "memory"); | ||
51 | break; | ||
52 | } | ||
53 | |||
54 | local_irq_restore(flags); | ||
55 | return tmp; | ||
56 | } | ||
57 | |||
58 | #include <asm-generic/cmpxchg.h> | ||
59 | #include <asm-generic/cmpxchg-local.h> | ||
60 | |||
61 | #endif /* _ASM_NIOS2_CMPXCHG_H */ | ||
diff --git a/arch/nios2/include/asm/linkage.h b/arch/nios2/include/asm/linkage.h new file mode 100644 index 000000000000..e0c6decd7d58 --- /dev/null +++ b/arch/nios2/include/asm/linkage.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 Thomas Chou <thomas@wytron.com.tw> | ||
3 | * | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
14 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
15 | * details. | ||
16 | */ | ||
17 | |||
18 | #ifndef _ASM_NIOS2_LINKAGE_H | ||
19 | #define _ASM_NIOS2_LINKAGE_H | ||
20 | |||
21 | /* This file is required by include/linux/linkage.h */ | ||
22 | #define __ALIGN .align 4 | ||
23 | #define __ALIGN_STR ".align 4" | ||
24 | |||
25 | #endif | ||
diff --git a/arch/nios2/include/asm/mutex.h b/arch/nios2/include/asm/mutex.h new file mode 100644 index 000000000000..ff6101aa2c71 --- /dev/null +++ b/arch/nios2/include/asm/mutex.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/mutex-dec.h> | |||
diff --git a/arch/nios2/include/uapi/asm/byteorder.h b/arch/nios2/include/uapi/asm/byteorder.h new file mode 100644 index 000000000000..3ab5dc20d757 --- /dev/null +++ b/arch/nios2/include/uapi/asm/byteorder.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 Thomas Chou <thomas@wytron.com.tw> | ||
3 | * Copyright (C) 2004 Microtronix Datacom Ltd | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #ifndef _ASM_NIOS2_BYTEORDER_H | ||
18 | #define _ASM_NIOS2_BYTEORDER_H | ||
19 | |||
20 | #include <linux/byteorder/little_endian.h> | ||
21 | |||
22 | #endif | ||
diff --git a/arch/nios2/include/uapi/asm/swab.h b/arch/nios2/include/uapi/asm/swab.h new file mode 100644 index 000000000000..b4e22ebaeb17 --- /dev/null +++ b/arch/nios2/include/uapi/asm/swab.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Tobias Klauser <tklauser@distanz.ch> | ||
3 | * Copyright (C) 2011 Pyramid Technical Consultants, Inc. | ||
4 | * | ||
5 | * This file is subject to the terms and conditions of the GNU General | ||
6 | * Public License. See the file COPYING in the main directory of this | ||
7 | * archive for more details. | ||
8 | */ | ||
9 | |||
10 | #ifndef _ASM_NIOS2_SWAB_H | ||
11 | #define _ASM_NIOS2_SWAB_H | ||
12 | |||
13 | #include <linux/types.h> | ||
14 | #include <asm-generic/swab.h> | ||
15 | |||
16 | #ifdef CONFIG_NIOS2_CI_SWAB_SUPPORT | ||
17 | #ifdef __GNUC__ | ||
18 | |||
19 | #define __nios2_swab(x) \ | ||
20 | __builtin_custom_ini(CONFIG_NIOS2_CI_SWAB_NO, (x)) | ||
21 | |||
22 | static inline __attribute__((const)) __u16 __arch_swab16(__u16 x) | ||
23 | { | ||
24 | return (__u16) __nios2_swab(((__u32) x) << 16); | ||
25 | } | ||
26 | #define __arch_swab16 __arch_swab16 | ||
27 | |||
28 | static inline __attribute__((const)) __u32 __arch_swab32(__u32 x) | ||
29 | { | ||
30 | return (__u32) __nios2_swab(x); | ||
31 | } | ||
32 | #define __arch_swab32 __arch_swab32 | ||
33 | |||
34 | #endif /* __GNUC__ */ | ||
35 | #endif /* CONFIG_NIOS2_CI_SWAB_SUPPORT */ | ||
36 | |||
37 | #endif /* _ASM_NIOS2_SWAB_H */ | ||