···3232#error only <linux/bitops.h> can be included directly3333#endif34343535+/*3636+ * Little endian assembly atomic bitops.3737+ */3838+extern void set_bit(int nr, volatile unsigned long *p);3939+extern void clear_bit(int nr, volatile unsigned long *p);4040+extern void change_bit(int nr, volatile unsigned long *p);4141+extern int test_and_set_bit(int nr, volatile unsigned long *p);4242+extern int test_and_clear_bit(int nr, volatile unsigned long *p);4343+extern int test_and_change_bit(int nr, volatile unsigned long *p);4444+3545#include <asm-generic/bitops/builtin-__ffs.h>3646#include <asm-generic/bitops/builtin-ffs.h>3747#include <asm-generic/bitops/builtin-__fls.h>···5545#include <asm-generic/bitops/hweight.h>5646#include <asm-generic/bitops/lock.h>57475858-#include <asm-generic/bitops/atomic.h>5948#include <asm-generic/bitops/non-atomic.h>6049#include <asm-generic/bitops/le.h>6161-#include <asm-generic/bitops/ext2-atomic.h>5050+5151+/*5252+ * Ext2 is defined to use little-endian byte ordering.5353+ */5454+#define ext2_set_bit_atomic(lock, nr, p) test_and_set_bit_le(nr, p)5555+#define ext2_clear_bit_atomic(lock, nr, p) test_and_clear_bit_le(nr, p)62566357#endif /* __ASM_BITOPS_H */
···11+/*22+ * Based on arch/arm/lib/bitops.h33+ *44+ * Copyright (C) 2013 ARM Ltd.55+ *66+ * This program is free software; you can redistribute it and/or modify77+ * it under the terms of the GNU General Public License version 2 as88+ * published by the Free Software Foundation.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+ * You should have received a copy of the GNU General Public License1616+ * along with this program. If not, see <http://www.gnu.org/licenses/>.1717+ */1818+1919+#include <linux/linkage.h>2020+#include <asm/assembler.h>2121+2222+/*2323+ * x0: bits 5:0 bit offset2424+ * bits 63:6 word offset2525+ * x1: address2626+ */2727+ .macro bitop, name, instr2828+ENTRY( \name )2929+ and x3, x0, #63 // Get bit offset3030+ eor x0, x0, x3 // Clear low bits3131+ mov x2, #13232+ add x1, x1, x0, lsr #3 // Get word offset3333+ lsl x3, x2, x3 // Create mask3434+1: ldxr x2, [x1]3535+ \instr x2, x2, x33636+ stxr w0, x2, [x1]3737+ cbnz w0, 1b3838+ ret3939+ENDPROC(\name )4040+ .endm4141+4242+ .macro testop, name, instr4343+ENTRY( \name )4444+ and x3, x0, #63 // Get bit offset4545+ eor x0, x0, x3 // Clear low bits4646+ mov x2, #14747+ add x1, x1, x0, lsr #3 // Get word offset4848+ lsl x4, x2, x3 // Create mask4949+ smp_dmb ish5050+1: ldxr x2, [x1]5151+ lsr x0, x2, x3 // Save old value of bit5252+ \instr x2, x2, x4 // toggle bit5353+ stxr w2, x2, [x1]5454+ cbnz w2, 1b5555+ smp_dmb ish5656+ and x0, x0, #15757+3: ret5858+ENDPROC(\name )5959+ .endm6060+6161+/*6262+ * Atomic bit operations.6363+ */6464+ bitop change_bit, eor6565+ bitop clear_bit, bic6666+ bitop set_bit, orr6767+6868+ testop test_and_change_bit, eor6969+ testop test_and_clear_bit, bic7070+ testop test_and_set_bit, orr
···11/*22- * Copyright (C) 2012 ARM Limited22+ * Copyright (C) 2013 ARM Ltd.33 *44 * This program is free software; you can redistribute it and/or modify55 * it under the terms of the GNU General Public License version 2 as···1313 * You should have received a copy of the GNU General Public License1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.1515 */1616+#ifndef __ASM_STRING_H1717+#define __ASM_STRING_H16181717-#include <linux/kernel.h>1818-#include <linux/spinlock.h>1919-#include <linux/atomic.h>1919+#define __HAVE_ARCH_STRRCHR2020+extern char *strrchr(const char *, int c);20212121-#ifdef CONFIG_SMP2222-arch_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned = {2323- [0 ... (ATOMIC_HASH_SIZE-1)] = __ARCH_SPIN_LOCK_UNLOCKED2424-};2222+#define __HAVE_ARCH_STRCHR2323+extern char *strchr(const char *, int c);2424+2525+#define __HAVE_ARCH_MEMCPY2626+extern void *memcpy(void *, const void *, __kernel_size_t);2727+2828+#define __HAVE_ARCH_MEMMOVE2929+extern void *memmove(void *, const void *, __kernel_size_t);3030+3131+#define __HAVE_ARCH_MEMCHR3232+extern void *memchr(const void *, int, __kernel_size_t);3333+3434+#define __HAVE_ARCH_MEMSET3535+extern void *memset(void *, int, __kernel_size_t);3636+2537#endif
+44
arch/arm64/lib/memchr.S
···11+/*22+ * Based on arch/arm/lib/memchr.S33+ *44+ * Copyright (C) 1995-2000 Russell King55+ * Copyright (C) 2013 ARM Ltd.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License version 2 as99+ * published by the Free Software Foundation.1010+ *1111+ * This program is distributed in the hope that it will be useful,1212+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1313+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1414+ * GNU General Public License for more details.1515+ *1616+ * You should have received a copy of the GNU General Public License1717+ * along with this program. If not, see <http://www.gnu.org/licenses/>.1818+ */1919+2020+#include <linux/linkage.h>2121+#include <asm/assembler.h>2222+2323+/*2424+ * Find a character in an area of memory.2525+ *2626+ * Parameters:2727+ * x0 - buf2828+ * x1 - c2929+ * x2 - n3030+ * Returns:3131+ * x0 - address of first occurrence of 'c' or 03232+ */3333+ENTRY(memchr)3434+ and w1, w1, #0xff3535+1: subs x2, x2, #13636+ b.mi 2f3737+ ldrb w3, [x0], #13838+ cmp w3, w13939+ b.ne 1b4040+ sub x0, x0, #14141+ ret4242+2: mov x0, #04343+ ret4444+ENDPROC(memchr)
+53
arch/arm64/lib/memcpy.S
···11+/*22+ * Copyright (C) 2013 ARM Ltd.33+ *44+ * This program is free software; you can redistribute it and/or modify55+ * it under the terms of the GNU General Public License version 2 as66+ * published by the Free Software Foundation.77+ *88+ * This program is distributed in the hope that it will be useful,99+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1010+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1111+ * GNU General Public License for more details.1212+ *1313+ * You should have received a copy of the GNU General Public License1414+ * along with this program. If not, see <http://www.gnu.org/licenses/>.1515+ */1616+1717+#include <linux/linkage.h>1818+#include <asm/assembler.h>1919+2020+/*2121+ * Copy a buffer from src to dest (alignment handled by the hardware)2222+ *2323+ * Parameters:2424+ * x0 - dest2525+ * x1 - src2626+ * x2 - n2727+ * Returns:2828+ * x0 - dest2929+ */3030+ENTRY(memcpy)3131+ mov x4, x03232+ subs x2, x2, #83333+ b.mi 2f3434+1: ldr x3, [x1], #83535+ subs x2, x2, #83636+ str x3, [x4], #83737+ b.pl 1b3838+2: adds x2, x2, #43939+ b.mi 3f4040+ ldr w3, [x1], #44141+ sub x2, x2, #44242+ str w3, [x4], #44343+3: adds x2, x2, #24444+ b.mi 4f4545+ ldrh w3, [x1], #24646+ sub x2, x2, #24747+ strh w3, [x4], #24848+4: adds x2, x2, #14949+ b.mi 5f5050+ ldrb w3, [x1]5151+ strb w3, [x4]5252+5: ret5353+ENDPROC(memcpy)
+57
arch/arm64/lib/memmove.S
···11+/*22+ * Copyright (C) 2013 ARM Ltd.33+ *44+ * This program is free software; you can redistribute it and/or modify55+ * it under the terms of the GNU General Public License version 2 as66+ * published by the Free Software Foundation.77+ *88+ * This program is distributed in the hope that it will be useful,99+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1010+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1111+ * GNU General Public License for more details.1212+ *1313+ * You should have received a copy of the GNU General Public License1414+ * along with this program. If not, see <http://www.gnu.org/licenses/>.1515+ */1616+1717+#include <linux/linkage.h>1818+#include <asm/assembler.h>1919+2020+/*2121+ * Move a buffer from src to test (alignment handled by the hardware).2222+ * If dest <= src, call memcpy, otherwise copy in reverse order.2323+ *2424+ * Parameters:2525+ * x0 - dest2626+ * x1 - src2727+ * x2 - n2828+ * Returns:2929+ * x0 - dest3030+ */3131+ENTRY(memmove)3232+ cmp x0, x13333+ b.ls memcpy3434+ add x4, x0, x23535+ add x1, x1, x23636+ subs x2, x2, #83737+ b.mi 2f3838+1: ldr x3, [x1, #-8]!3939+ subs x2, x2, #84040+ str x3, [x4, #-8]!4141+ b.pl 1b4242+2: adds x2, x2, #44343+ b.mi 3f4444+ ldr w3, [x1, #-4]!4545+ sub x2, x2, #44646+ str w3, [x4, #-4]!4747+3: adds x2, x2, #24848+ b.mi 4f4949+ ldrh w3, [x1, #-2]!5050+ sub x2, x2, #25151+ strh w3, [x4, #-2]!5252+4: adds x2, x2, #15353+ b.mi 5f5454+ ldrb w3, [x1, #-1]5555+ strb w3, [x4, #-1]5656+5: ret5757+ENDPROC(memmove)
+53
arch/arm64/lib/memset.S
···11+/*22+ * Copyright (C) 2013 ARM Ltd.33+ *44+ * This program is free software; you can redistribute it and/or modify55+ * it under the terms of the GNU General Public License version 2 as66+ * published by the Free Software Foundation.77+ *88+ * This program is distributed in the hope that it will be useful,99+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1010+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1111+ * GNU General Public License for more details.1212+ *1313+ * You should have received a copy of the GNU General Public License1414+ * along with this program. If not, see <http://www.gnu.org/licenses/>.1515+ */1616+1717+#include <linux/linkage.h>1818+#include <asm/assembler.h>1919+2020+/*2121+ * Fill in the buffer with character c (alignment handled by the hardware)2222+ *2323+ * Parameters:2424+ * x0 - buf2525+ * x1 - c2626+ * x2 - n2727+ * Returns:2828+ * x0 - buf2929+ */3030+ENTRY(memset)3131+ mov x4, x03232+ and w1, w1, #0xff3333+ orr w1, w1, w1, lsl #83434+ orr w1, w1, w1, lsl #163535+ orr x1, x1, x1, lsl #323636+ subs x2, x2, #83737+ b.mi 2f3838+1: str x1, [x4], #83939+ subs x2, x2, #84040+ b.pl 1b4141+2: adds x2, x2, #44242+ b.mi 3f4343+ sub x2, x2, #44444+ str w1, [x4], #44545+3: adds x2, x2, #24646+ b.mi 4f4747+ sub x2, x2, #24848+ strh w1, [x4], #24949+4: adds x2, x2, #15050+ b.mi 5f5151+ strb w1, [x4]5252+5: ret5353+ENDPROC(memset)
+42
arch/arm64/lib/strchr.S
···11+/*22+ * Based on arch/arm/lib/strchr.S33+ *44+ * Copyright (C) 1995-2000 Russell King55+ * Copyright (C) 2013 ARM Ltd.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License version 2 as99+ * published by the Free Software Foundation.1010+ *1111+ * This program is distributed in the hope that it will be useful,1212+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1313+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1414+ * GNU General Public License for more details.1515+ *1616+ * You should have received a copy of the GNU General Public License1717+ * along with this program. If not, see <http://www.gnu.org/licenses/>.1818+ */1919+2020+#include <linux/linkage.h>2121+#include <asm/assembler.h>2222+2323+/*2424+ * Find the first occurrence of a character in a string.2525+ *2626+ * Parameters:2727+ * x0 - str2828+ * x1 - c2929+ * Returns:3030+ * x0 - address of first occurrence of 'c' or 03131+ */3232+ENTRY(strchr)3333+ and w1, w1, #0xff3434+1: ldrb w2, [x0], #13535+ cmp w2, w13636+ ccmp w2, wzr, #4, ne3737+ b.ne 1b3838+ sub x0, x0, #13939+ cmp w2, w14040+ csel x0, x0, xzr, eq4141+ ret4242+ENDPROC(strchr)
+43
arch/arm64/lib/strrchr.S
···11+/*22+ * Based on arch/arm/lib/strrchr.S33+ *44+ * Copyright (C) 1995-2000 Russell King55+ * Copyright (C) 2013 ARM Ltd.66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License version 2 as99+ * published by the Free Software Foundation.1010+ *1111+ * This program is distributed in the hope that it will be useful,1212+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1313+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1414+ * GNU General Public License for more details.1515+ *1616+ * You should have received a copy of the GNU General Public License1717+ * along with this program. If not, see <http://www.gnu.org/licenses/>.1818+ */1919+2020+#include <linux/linkage.h>2121+#include <asm/assembler.h>2222+2323+/*2424+ * Find the last occurrence of a character in a string.2525+ *2626+ * Parameters:2727+ * x0 - str2828+ * x1 - c2929+ * Returns:3030+ * x0 - address of last occurrence of 'c' or 03131+ */3232+ENTRY(strrchr)3333+ mov x3, #03434+ and w1, w1, #0xff3535+1: ldrb w2, [x0], #13636+ cbz w2, 2f3737+ cmp w2, w13838+ b.ne 1b3939+ sub x3, x0, #14040+ b 1b4141+2: mov x0, x34242+ ret4343+ENDPROC(strrchr)