Sean Anderson | 6babd84 | 2023-07-31 17:27:33 -0400 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * Copyright (C) 2023 Sean Anderson <sean.anderson@seco.com> |
| 4 | * |
| 5 | * ARM bitops to call when using THUMB1, which doesn't have these instructions. |
| 6 | */ |
| 7 | #include <linux/linkage.h> |
| 8 | #include <asm/assembler.h> |
| 9 | |
| 10 | .pushsection .text.__fls |
| 11 | ENTRY(__fls) |
| 12 | clz r0, r0 |
| 13 | rsb r0, r0, #31 |
| 14 | ret lr |
| 15 | ENDPROC(__fls) |
| 16 | .popsection |
| 17 | |
| 18 | .pushsection .text.__ffs |
| 19 | ENTRY(__ffs) |
| 20 | rsb r3, r0, #0 |
| 21 | and r0, r0, r3 |
| 22 | clz r0, r0 |
| 23 | rsb r0, r0, #31 |
| 24 | ret lr |
| 25 | ENDPROC(__ffs) |
| 26 | .popsection |
| 27 | |
| 28 | .pushsection .text.fls |
| 29 | ENTRY(fls) |
| 30 | cmp r0, #0 |
| 31 | clzne r0, r0 |
| 32 | rsbne r0, r0, #32 |
| 33 | ret lr |
| 34 | ENDPROC(fls) |
| 35 | .popsection |
| 36 | |
| 37 | .pushsection .text.ffs |
| 38 | ENTRY(ffs) |
| 39 | rsb r3, r0, #0 |
| 40 | and r0, r0, r3 |
| 41 | clz r0, r0 |
| 42 | rsb r0, r0, #32 |
| 43 | ret lr |
| 44 | ENDPROC(ffs) |
| 45 | .popsection |