/*1* Copyright (C) 2006 Atmel Corporation2*3* This program is free software; you can redistribute it and/or modify4* it under the terms of the GNU General Public License version 2 as5* published by the Free Software Foundation.6*/7#include <linux/linkage.h>89.text10/*11* unsigned long find_first_zero_bit(const unsigned long *addr,12* unsigned long size)13*/14ENTRY(find_first_zero_bit)15cp.w r11, 016reteq r1117mov r9, r11181: ld.w r8, r12[0]19com r820brne .L_found21sub r12, -422sub r9, 3223brgt 1b24retal r112526/*27* unsigned long find_next_zero_bit(const unsigned long *addr,28* unsigned long size,29* unsigned long offset)30*/31ENTRY(find_next_zero_bit)32lsr r8, r10, 533sub r9, r11, r1034retle r113536lsl r8, 237add r12, r838andl r10, 31, COH39breq 1f4041/* offset is not word-aligned. Handle the first (32 - r10) bits */42ld.w r8, r12[0]43com r844sub r12, -445lsr r8, r8, r1046brne .L_found4748/* r9 = r9 - (32 - r10) = r9 + r10 - 32 */49add r9, r1050sub r9, 3251retle r115253/* Main loop. offset must be word-aligned */541: ld.w r8, r12[0]55com r856brne .L_found57sub r12, -458sub r9, 3259brgt 1b60retal r116162/* Common return path for when a bit is actually found. */63.L_found:64brev r865clz r10, r866rsub r9, r1167add r10, r96869/* XXX: If we don't have to return exactly "size" when the bit70is not found, we may drop this "min" thing */71min r12, r11, r1072retal r127374/*75* unsigned long find_first_bit(const unsigned long *addr,76* unsigned long size)77*/78ENTRY(find_first_bit)79cp.w r11, 080reteq r1181mov r9, r11821: ld.w r8, r12[0]83cp.w r8, 084brne .L_found85sub r12, -486sub r9, 3287brgt 1b88retal r118990/*91* unsigned long find_next_bit(const unsigned long *addr,92* unsigned long size,93* unsigned long offset)94*/95ENTRY(find_next_bit)96lsr r8, r10, 597sub r9, r11, r1098retle r1199100lsl r8, 2101add r12, r8102andl r10, 31, COH103breq 1f104105/* offset is not word-aligned. Handle the first (32 - r10) bits */106ld.w r8, r12[0]107sub r12, -4108lsr r8, r8, r10109brne .L_found110111/* r9 = r9 - (32 - r10) = r9 + r10 - 32 */112add r9, r10113sub r9, 32114retle r11115116/* Main loop. offset must be word-aligned */1171: ld.w r8, r12[0]118cp.w r8, 0119brne .L_found120sub r12, -4121sub r9, 32122brgt 1b123retal r11124125ENTRY(find_next_bit_le)126lsr r8, r10, 5127sub r9, r11, r10128retle r11129130lsl r8, 2131add r12, r8132andl r10, 31, COH133breq 1f134135/* offset is not word-aligned. Handle the first (32 - r10) bits */136ldswp.w r8, r12[0]137sub r12, -4138lsr r8, r8, r10139brne .L_found140141/* r9 = r9 - (32 - r10) = r9 + r10 - 32 */142add r9, r10143sub r9, 32144retle r11145146/* Main loop. offset must be word-aligned */1471: ldswp.w r8, r12[0]148cp.w r8, 0149brne .L_found150sub r12, -4151sub r9, 32152brgt 1b153retal r11154155ENTRY(find_next_zero_bit_le)156lsr r8, r10, 5157sub r9, r11, r10158retle r11159160lsl r8, 2161add r12, r8162andl r10, 31, COH163breq 1f164165/* offset is not word-aligned. Handle the first (32 - r10) bits */166ldswp.w r8, r12[0]167sub r12, -4168com r8169lsr r8, r8, r10170brne .L_found171172/* r9 = r9 - (32 - r10) = r9 + r10 - 32 */173add r9, r10174sub r9, 32175retle r11176177/* Main loop. offset must be word-aligned */1781: ldswp.w r8, r12[0]179com r8180brne .L_found181sub r12, -4182sub r9, 32183brgt 1b184retal r11185186187