Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nios2: Miscellaneous header files

This patch introduces a few nios2-specific header files.

Signed-off-by: Ley Foon Tan <lftan@altera.com>

+146
+61
arch/nios2/include/asm/cmpxchg.h
··· 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 */
+25
arch/nios2/include/asm/linkage.h
··· 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
+1
arch/nios2/include/asm/mutex.h
··· 1 + #include <asm-generic/mutex-dec.h>
+22
arch/nios2/include/uapi/asm/byteorder.h
··· 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
+37
arch/nios2/include/uapi/asm/swab.h
··· 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 */