Linux Audio

Check our new training course

Loading...
v6.13.7
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 *  linux/arch/arm/lib/memset.S
  4 *
  5 *  Copyright (C) 1995-2000 Russell King
  6 *
 
 
 
 
  7 *  ASM optimised string functions
  8 */
  9#include <linux/linkage.h>
 10#include <asm/assembler.h>
 11#include <asm/unwind.h>
 12
 13	.text
 14	.align	5
 
 
 
 
 
 
 
 
 
 
 
 
 
 15
 16ENTRY(__memset)
 17ENTRY(mmioset)
 18WEAK(memset)
 19UNWIND( .fnstart         )
 20	and	r1, r1, #255		@ cast to unsigned char
 21	ands	r3, r0, #3		@ 1 unaligned?
 22	mov	ip, r0			@ preserve r0 as return value
 23	bne	6f			@ 1
 24/*
 25 * we know that the pointer in ip is aligned to a word boundary.
 26 */
 271:	orr	r1, r1, r1, lsl #8
 28	orr	r1, r1, r1, lsl #16
 29	mov	r3, r1
 307:	cmp	r2, #16
 31	blt	4f
 32UNWIND( .fnend              )
 33
 34#if ! CALGN(1)+0
 35
 36/*
 37 * We need 2 extra registers for this loop - use r8 and the LR
 
 38 */
 39UNWIND( .fnstart            )
 40UNWIND( .save {r8, lr}      )
 41	stmfd	sp!, {r8, lr}
 42	mov	r8, r1
 43	mov	lr, r3
 44
 452:	subs	r2, r2, #64
 46	stmiage	ip!, {r1, r3, r8, lr}	@ 64 bytes at a time.
 47	stmiage	ip!, {r1, r3, r8, lr}
 48	stmiage	ip!, {r1, r3, r8, lr}
 49	stmiage	ip!, {r1, r3, r8, lr}
 50	bgt	2b
 51	ldmfdeq	sp!, {r8, pc}		@ Now <64 bytes to go.
 52/*
 53 * No need to correct the count; we're only testing bits from now on
 54 */
 55	tst	r2, #32
 56	stmiane	ip!, {r1, r3, r8, lr}
 57	stmiane	ip!, {r1, r3, r8, lr}
 58	tst	r2, #16
 59	stmiane	ip!, {r1, r3, r8, lr}
 60	ldmfd	sp!, {r8, lr}
 61UNWIND( .fnend              )
 62
 63#else
 64
 65/*
 66 * This version aligns the destination pointer in order to write
 67 * whole cache lines at once.
 68 */
 69
 70UNWIND( .fnstart               )
 71UNWIND( .save {r4-r8, lr}      )
 72	stmfd	sp!, {r4-r8, lr}
 73	mov	r4, r1
 74	mov	r5, r3
 75	mov	r6, r1
 76	mov	r7, r3
 77	mov	r8, r1
 78	mov	lr, r3
 79
 80	cmp	r2, #96
 81	tstgt	ip, #31
 82	ble	3f
 83
 84	and	r8, ip, #31
 85	rsb	r8, r8, #32
 86	sub	r2, r2, r8
 87	movs	r8, r8, lsl #(32 - 4)
 88	stmiacs	ip!, {r4, r5, r6, r7}
 89	stmiami	ip!, {r4, r5}
 90	tst	r8, #(1 << 30)
 91	mov	r8, r1
 92	strne	r1, [ip], #4
 93
 943:	subs	r2, r2, #64
 95	stmiage	ip!, {r1, r3-r8, lr}
 96	stmiage	ip!, {r1, r3-r8, lr}
 97	bgt	3b
 98	ldmfdeq	sp!, {r4-r8, pc}
 99
100	tst	r2, #32
101	stmiane	ip!, {r1, r3-r8, lr}
102	tst	r2, #16
103	stmiane	ip!, {r4-r7}
104	ldmfd	sp!, {r4-r8, lr}
105UNWIND( .fnend                 )
106
107#endif
108
109UNWIND( .fnstart            )
1104:	tst	r2, #8
111	stmiane	ip!, {r1, r3}
112	tst	r2, #4
113	strne	r1, [ip], #4
114/*
115 * When we get here, we've got less than 4 bytes to set.  We
116 * may have an unaligned pointer as well.
117 */
1185:	tst	r2, #2
119	strbne	r1, [ip], #1
120	strbne	r1, [ip], #1
121	tst	r2, #1
122	strbne	r1, [ip], #1
123	ret	lr
124
1256:	subs	r2, r2, #4		@ 1 do we have enough
126	blt	5b			@ 1 bytes to align with?
127	cmp	r3, #2			@ 1
128	strblt	r1, [ip], #1		@ 1
129	strble	r1, [ip], #1		@ 1
130	strb	r1, [ip], #1		@ 1
131	add	r2, r2, r3		@ 1 (r2 = r2 - (4 - r3))
132	b	1b
133UNWIND( .fnend   )
134ENDPROC(memset)
135ENDPROC(mmioset)
136ENDPROC(__memset)
137
138ENTRY(__memset32)
139UNWIND( .fnstart         )
140	mov	r3, r1			@ copy r1 to r3 and fall into memset64
141UNWIND( .fnend   )
142ENDPROC(__memset32)
143ENTRY(__memset64)
144UNWIND( .fnstart         )
145	mov	ip, r0			@ preserve r0 as return value
146	b	7b			@ jump into the middle of memset
147UNWIND( .fnend   )
148ENDPROC(__memset64)
v3.5.6
 
  1/*
  2 *  linux/arch/arm/lib/memset.S
  3 *
  4 *  Copyright (C) 1995-2000 Russell King
  5 *
  6 * This program is free software; you can redistribute it and/or modify
  7 * it under the terms of the GNU General Public License version 2 as
  8 * published by the Free Software Foundation.
  9 *
 10 *  ASM optimised string functions
 11 */
 12#include <linux/linkage.h>
 13#include <asm/assembler.h>
 
 14
 15	.text
 16	.align	5
 17	.word	0
 18
 191:	subs	r2, r2, #4		@ 1 do we have enough
 20	blt	5f			@ 1 bytes to align with?
 21	cmp	r3, #2			@ 1
 22	strltb	r1, [r0], #1		@ 1
 23	strleb	r1, [r0], #1		@ 1
 24	strb	r1, [r0], #1		@ 1
 25	add	r2, r2, r3		@ 1 (r2 = r2 - (4 - r3))
 26/*
 27 * The pointer is now aligned and the length is adjusted.  Try doing the
 28 * memset again.
 29 */
 30
 31ENTRY(memset)
 
 
 
 
 32	ands	r3, r0, #3		@ 1 unaligned?
 33	bne	1b			@ 1
 
 34/*
 35 * we know that the pointer in r0 is aligned to a word boundary.
 36 */
 37	orr	r1, r1, r1, lsl #8
 38	orr	r1, r1, r1, lsl #16
 39	mov	r3, r1
 40	cmp	r2, #16
 41	blt	4f
 
 42
 43#if ! CALGN(1)+0
 44
 45/*
 46 * We need an extra register for this loop - save the return address and
 47 * use the LR
 48 */
 49	str	lr, [sp, #-4]!
 50	mov	ip, r1
 51	mov	lr, r1
 
 
 52
 532:	subs	r2, r2, #64
 54	stmgeia	r0!, {r1, r3, ip, lr}	@ 64 bytes at a time.
 55	stmgeia	r0!, {r1, r3, ip, lr}
 56	stmgeia	r0!, {r1, r3, ip, lr}
 57	stmgeia	r0!, {r1, r3, ip, lr}
 58	bgt	2b
 59	ldmeqfd	sp!, {pc}		@ Now <64 bytes to go.
 60/*
 61 * No need to correct the count; we're only testing bits from now on
 62 */
 63	tst	r2, #32
 64	stmneia	r0!, {r1, r3, ip, lr}
 65	stmneia	r0!, {r1, r3, ip, lr}
 66	tst	r2, #16
 67	stmneia	r0!, {r1, r3, ip, lr}
 68	ldr	lr, [sp], #4
 
 69
 70#else
 71
 72/*
 73 * This version aligns the destination pointer in order to write
 74 * whole cache lines at once.
 75 */
 76
 77	stmfd	sp!, {r4-r7, lr}
 
 
 78	mov	r4, r1
 79	mov	r5, r1
 80	mov	r6, r1
 81	mov	r7, r1
 82	mov	ip, r1
 83	mov	lr, r1
 84
 85	cmp	r2, #96
 86	tstgt	r0, #31
 87	ble	3f
 88
 89	and	ip, r0, #31
 90	rsb	ip, ip, #32
 91	sub	r2, r2, ip
 92	movs	ip, ip, lsl #(32 - 4)
 93	stmcsia	r0!, {r4, r5, r6, r7}
 94	stmmiia	r0!, {r4, r5}
 95	tst	ip, #(1 << 30)
 96	mov	ip, r1
 97	strne	r1, [r0], #4
 98
 993:	subs	r2, r2, #64
100	stmgeia	r0!, {r1, r3-r7, ip, lr}
101	stmgeia	r0!, {r1, r3-r7, ip, lr}
102	bgt	3b
103	ldmeqfd	sp!, {r4-r7, pc}
104
105	tst	r2, #32
106	stmneia	r0!, {r1, r3-r7, ip, lr}
107	tst	r2, #16
108	stmneia	r0!, {r4-r7}
109	ldmfd	sp!, {r4-r7, lr}
 
110
111#endif
112
 
1134:	tst	r2, #8
114	stmneia	r0!, {r1, r3}
115	tst	r2, #4
116	strne	r1, [r0], #4
117/*
118 * When we get here, we've got less than 4 bytes to zero.  We
119 * may have an unaligned pointer as well.
120 */
1215:	tst	r2, #2
122	strneb	r1, [r0], #1
123	strneb	r1, [r0], #1
124	tst	r2, #1
125	strneb	r1, [r0], #1
126	mov	pc, lr
 
 
 
 
 
 
 
 
 
 
127ENDPROC(memset)