···11+/*22+ * Copyright (C) 2004 Microtronix Datacom Ltd.33+ *44+ * This file is subject to the terms and conditions of the GNU General Public55+ * License. See the file "COPYING" in the main directory of this archive66+ * for more details.77+ */88+99+#ifndef _ASM_NIOS2_CMPXCHG_H1010+#define _ASM_NIOS2_CMPXCHG_H1111+1212+#include <linux/irqflags.h>1313+1414+#define xchg(ptr, x) \1515+ ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))1616+1717+struct __xchg_dummy { unsigned long a[100]; };1818+#define __xg(x) ((volatile struct __xchg_dummy *)(x))1919+2020+static inline unsigned long __xchg(unsigned long x, volatile void *ptr,2121+ int size)2222+{2323+ unsigned long tmp, flags;2424+2525+ local_irq_save(flags);2626+2727+ switch (size) {2828+ case 1:2929+ __asm__ __volatile__(3030+ "ldb %0, %2\n"3131+ "stb %1, %2\n"3232+ : "=&r" (tmp)3333+ : "r" (x), "m" (*__xg(ptr))3434+ : "memory");3535+ break;3636+ case 2:3737+ __asm__ __volatile__(3838+ "ldh %0, %2\n"3939+ "sth %1, %2\n"4040+ : "=&r" (tmp)4141+ : "r" (x), "m" (*__xg(ptr))4242+ : "memory");4343+ break;4444+ case 4:4545+ __asm__ __volatile__(4646+ "ldw %0, %2\n"4747+ "stw %1, %2\n"4848+ : "=&r" (tmp)4949+ : "r" (x), "m" (*__xg(ptr))5050+ : "memory");5151+ break;5252+ }5353+5454+ local_irq_restore(flags);5555+ return tmp;5656+}5757+5858+#include <asm-generic/cmpxchg.h>5959+#include <asm-generic/cmpxchg-local.h>6060+6161+#endif /* _ASM_NIOS2_CMPXCHG_H */
+25
arch/nios2/include/asm/linkage.h
···11+/*22+ * Copyright (C) 2009 Thomas Chou <thomas@wytron.com.tw>33+ *44+ * All rights reserved.55+ *66+ * This program is free software; you can redistribute it and/or modify77+ * it under the terms of the GNU General Public License as published by88+ * the Free Software Foundation; either version 2 of the License, or99+ * (at your option) any later version.1010+ *1111+ * This program is distributed in the hope that it will be useful, but1212+ * WITHOUT ANY WARRANTY; without even the implied warranty of1313+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or1414+ * NON INFRINGEMENT. See the GNU General Public License for more1515+ * details.1616+ */1717+1818+#ifndef _ASM_NIOS2_LINKAGE_H1919+#define _ASM_NIOS2_LINKAGE_H2020+2121+/* This file is required by include/linux/linkage.h */2222+#define __ALIGN .align 42323+#define __ALIGN_STR ".align 4"2424+2525+#endif
···11+/*22+ * Copyright (C) 2009 Thomas Chou <thomas@wytron.com.tw>33+ * Copyright (C) 2004 Microtronix Datacom Ltd44+ *55+ * This program is free software; you can redistribute it and/or modify66+ * it under the terms of the GNU General Public License as published by77+ * the Free Software Foundation; either version 2 of the License, or88+ * (at your option) any later version.99+ *1010+ * This program is distributed in the hope that it will be useful,1111+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1313+ * GNU General Public License for more details.1414+ *1515+ */1616+1717+#ifndef _ASM_NIOS2_BYTEORDER_H1818+#define _ASM_NIOS2_BYTEORDER_H1919+2020+#include <linux/byteorder/little_endian.h>2121+2222+#endif
+37
arch/nios2/include/uapi/asm/swab.h
···11+/*22+ * Copyright (C) 2012 Tobias Klauser <tklauser@distanz.ch>33+ * Copyright (C) 2011 Pyramid Technical Consultants, Inc.44+ *55+ * This file is subject to the terms and conditions of the GNU General66+ * Public License. See the file COPYING in the main directory of this77+ * archive for more details.88+ */99+1010+#ifndef _ASM_NIOS2_SWAB_H1111+#define _ASM_NIOS2_SWAB_H1212+1313+#include <linux/types.h>1414+#include <asm-generic/swab.h>1515+1616+#ifdef CONFIG_NIOS2_CI_SWAB_SUPPORT1717+#ifdef __GNUC__1818+1919+#define __nios2_swab(x) \2020+ __builtin_custom_ini(CONFIG_NIOS2_CI_SWAB_NO, (x))2121+2222+static inline __attribute__((const)) __u16 __arch_swab16(__u16 x)2323+{2424+ return (__u16) __nios2_swab(((__u32) x) << 16);2525+}2626+#define __arch_swab16 __arch_swab162727+2828+static inline __attribute__((const)) __u32 __arch_swab32(__u32 x)2929+{3030+ return (__u32) __nios2_swab(x);3131+}3232+#define __arch_swab32 __arch_swab323333+3434+#endif /* __GNUC__ */3535+#endif /* CONFIG_NIOS2_CI_SWAB_SUPPORT */3636+3737+#endif /* _ASM_NIOS2_SWAB_H */