1*4a899227SCatalin Marinas/* 2*4a899227SCatalin Marinas * Based on arch/arm/lib/memchr.S 3*4a899227SCatalin Marinas * 4*4a899227SCatalin Marinas * Copyright (C) 1995-2000 Russell King 5*4a899227SCatalin Marinas * Copyright (C) 2013 ARM Ltd. 6*4a899227SCatalin Marinas * 7*4a899227SCatalin Marinas * This program is free software; you can redistribute it and/or modify 8*4a899227SCatalin Marinas * it under the terms of the GNU General Public License version 2 as 9*4a899227SCatalin Marinas * published by the Free Software Foundation. 10*4a899227SCatalin Marinas * 11*4a899227SCatalin Marinas * This program is distributed in the hope that it will be useful, 12*4a899227SCatalin Marinas * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*4a899227SCatalin Marinas * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*4a899227SCatalin Marinas * GNU General Public License for more details. 15*4a899227SCatalin Marinas * 16*4a899227SCatalin Marinas * You should have received a copy of the GNU General Public License 17*4a899227SCatalin Marinas * along with this program. If not, see <http://www.gnu.org/licenses/>. 18*4a899227SCatalin Marinas */ 19*4a899227SCatalin Marinas 20*4a899227SCatalin Marinas#include <linux/linkage.h> 21*4a899227SCatalin Marinas#include <asm/assembler.h> 22*4a899227SCatalin Marinas 23*4a899227SCatalin Marinas/* 24*4a899227SCatalin Marinas * Find a character in an area of memory. 25*4a899227SCatalin Marinas * 26*4a899227SCatalin Marinas * Parameters: 27*4a899227SCatalin Marinas * x0 - buf 28*4a899227SCatalin Marinas * x1 - c 29*4a899227SCatalin Marinas * x2 - n 30*4a899227SCatalin Marinas * Returns: 31*4a899227SCatalin Marinas * x0 - address of first occurrence of 'c' or 0 32*4a899227SCatalin Marinas */ 33*4a899227SCatalin MarinasENTRY(memchr) 34*4a899227SCatalin Marinas and w1, w1, #0xff 35*4a899227SCatalin Marinas1: subs x2, x2, #1 36*4a899227SCatalin Marinas b.mi 2f 37*4a899227SCatalin Marinas ldrb w3, [x0], #1 38*4a899227SCatalin Marinas cmp w3, w1 39*4a899227SCatalin Marinas b.ne 1b 40*4a899227SCatalin Marinas sub x0, x0, #1 41*4a899227SCatalin Marinas ret 42*4a899227SCatalin Marinas2: mov x0, #0 43*4a899227SCatalin Marinas ret 44*4a899227SCatalin MarinasENDPROC(memchr) 45