Furquan Shaikh | 464f5ca | 2015-06-08 10:31:55 -0700 | [diff] [blame] | 1 | /* |
Martin Roth | 96c075a | 2019-07-28 19:50:52 -0600 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Furquan Shaikh | 464f5ca | 2015-06-08 10:31:55 -0700 | [diff] [blame] | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
Furquan Shaikh | 464f5ca | 2015-06-08 10:31:55 -0700 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <arch/asm.h> |
| 15 | |
| 16 | /* |
| 17 | * Fill in the buffer with character c (alignment handled by the hardware) |
| 18 | * |
| 19 | * Parameters: |
| 20 | * x0 - buf |
| 21 | * x1 - c |
| 22 | * x2 - n |
| 23 | * Returns: |
| 24 | * x0 - buf |
| 25 | */ |
| 26 | ENTRY(memset) |
| 27 | mov x4, x0 |
| 28 | and w1, w1, #0xff |
| 29 | orr w1, w1, w1, lsl #8 |
| 30 | orr w1, w1, w1, lsl #16 |
| 31 | orr x1, x1, x1, lsl #32 |
| 32 | subs x2, x2, #8 |
| 33 | b.mi 2f |
| 34 | 1: str x1, [x4], #8 |
| 35 | subs x2, x2, #8 |
| 36 | b.pl 1b |
| 37 | 2: adds x2, x2, #4 |
| 38 | b.mi 3f |
| 39 | sub x2, x2, #4 |
| 40 | str w1, [x4], #4 |
| 41 | 3: adds x2, x2, #2 |
| 42 | b.mi 4f |
| 43 | sub x2, x2, #2 |
| 44 | strh w1, [x4], #2 |
| 45 | 4: adds x2, x2, #1 |
| 46 | b.mi 5f |
| 47 | strb w1, [x4] |
| 48 | 5: ret |
| 49 | ENDPROC(memset) |