xref: /openbmc/linux/arch/powerpc/lib/string_32.S (revision 39326182)
1f36bbf21SChristophe Leroy/* SPDX-License-Identifier: GPL-2.0 */
2f36bbf21SChristophe Leroy
3f36bbf21SChristophe Leroy/*
4f36bbf21SChristophe Leroy * String handling functions for PowerPC32
5f36bbf21SChristophe Leroy *
6f36bbf21SChristophe Leroy * Copyright (C) 1996 Paul Mackerras.
7f36bbf21SChristophe Leroy *
8f36bbf21SChristophe Leroy */
9f36bbf21SChristophe Leroy
10*39326182SMasahiro Yamada#include <linux/export.h>
11f36bbf21SChristophe Leroy#include <asm/ppc_asm.h>
12f36bbf21SChristophe Leroy#include <asm/cache.h>
13f36bbf21SChristophe Leroy
14f36bbf21SChristophe Leroy	.text
15f36bbf21SChristophe Leroy
16f36bbf21SChristophe LeroyCACHELINE_BYTES = L1_CACHE_BYTES
17f36bbf21SChristophe LeroyLG_CACHELINE_BYTES = L1_CACHE_SHIFT
18f36bbf21SChristophe LeroyCACHELINE_MASK = (L1_CACHE_BYTES-1)
19f36bbf21SChristophe Leroy
2061e3acd8SAndrew Donnellan_GLOBAL(__arch_clear_user)
21f36bbf21SChristophe Leroy/*
22f36bbf21SChristophe Leroy * Use dcbz on the complete cache lines in the destination
23f36bbf21SChristophe Leroy * to set them to zero.  This requires that the destination
24f36bbf21SChristophe Leroy * area is cacheable.
25f36bbf21SChristophe Leroy */
26f36bbf21SChristophe Leroy	cmplwi	cr0, r4, 4
27f36bbf21SChristophe Leroy	mr	r10, r3
28f36bbf21SChristophe Leroy	li	r3, 0
29f36bbf21SChristophe Leroy	blt	7f
30f36bbf21SChristophe Leroy
31f36bbf21SChristophe Leroy11:	stw	r3, 0(r10)
32f36bbf21SChristophe Leroy	beqlr
33f36bbf21SChristophe Leroy	andi.	r0, r10, 3
34f36bbf21SChristophe Leroy	add	r11, r0, r4
35f36bbf21SChristophe Leroy	subf	r6, r0, r10
36f36bbf21SChristophe Leroy
37f36bbf21SChristophe Leroy	clrlwi	r7, r6, 32 - LG_CACHELINE_BYTES
38f36bbf21SChristophe Leroy	add	r8, r7, r11
39f36bbf21SChristophe Leroy	srwi	r9, r8, LG_CACHELINE_BYTES
40f36bbf21SChristophe Leroy	addic.	r9, r9, -1	/* total number of complete cachelines */
41f36bbf21SChristophe Leroy	ble	2f
42f36bbf21SChristophe Leroy	xori	r0, r7, CACHELINE_MASK & ~3
43f36bbf21SChristophe Leroy	srwi.	r0, r0, 2
44f36bbf21SChristophe Leroy	beq	3f
45f36bbf21SChristophe Leroy	mtctr	r0
46f36bbf21SChristophe Leroy4:	stwu	r3, 4(r6)
47f36bbf21SChristophe Leroy	bdnz	4b
48f36bbf21SChristophe Leroy3:	mtctr	r9
49f36bbf21SChristophe Leroy	li	r7, 4
50f36bbf21SChristophe Leroy10:	dcbz	r7, r6
51f36bbf21SChristophe Leroy	addi	r6, r6, CACHELINE_BYTES
52f36bbf21SChristophe Leroy	bdnz	10b
53f36bbf21SChristophe Leroy	clrlwi	r11, r8, 32 - LG_CACHELINE_BYTES
54f36bbf21SChristophe Leroy	addi	r11, r11, 4
55f36bbf21SChristophe Leroy
56f36bbf21SChristophe Leroy2:	srwi	r0 ,r11 ,2
57f36bbf21SChristophe Leroy	mtctr	r0
58f36bbf21SChristophe Leroy	bdz	6f
59f36bbf21SChristophe Leroy1:	stwu	r3, 4(r6)
60f36bbf21SChristophe Leroy	bdnz	1b
61f36bbf21SChristophe Leroy6:	andi.	r11, r11, 3
62f36bbf21SChristophe Leroy	beqlr
63f36bbf21SChristophe Leroy	mtctr	r11
64f36bbf21SChristophe Leroy	addi	r6, r6, 3
65f36bbf21SChristophe Leroy8:	stbu	r3, 1(r6)
66f36bbf21SChristophe Leroy	bdnz	8b
67f36bbf21SChristophe Leroy	blr
68f36bbf21SChristophe Leroy
69f36bbf21SChristophe Leroy7:	cmpwi	cr0, r4, 0
70f36bbf21SChristophe Leroy	beqlr
71f36bbf21SChristophe Leroy	mtctr	r4
72f36bbf21SChristophe Leroy	addi	r6, r10, -1
73f36bbf21SChristophe Leroy9:	stbu	r3, 1(r6)
74f36bbf21SChristophe Leroy	bdnz	9b
75f36bbf21SChristophe Leroy	blr
76f36bbf21SChristophe Leroy
77f36bbf21SChristophe Leroy90:	mr	r3, r4
78f36bbf21SChristophe Leroy	blr
79f36bbf21SChristophe Leroy91:	add	r3, r10, r4
80f36bbf21SChristophe Leroy	subf	r3, r6, r3
81f36bbf21SChristophe Leroy	blr
82f36bbf21SChristophe Leroy
83f36bbf21SChristophe Leroy	EX_TABLE(11b, 90b)
84f36bbf21SChristophe Leroy	EX_TABLE(4b, 91b)
85f36bbf21SChristophe Leroy	EX_TABLE(10b, 91b)
86f36bbf21SChristophe Leroy	EX_TABLE(1b, 91b)
87f36bbf21SChristophe Leroy	EX_TABLE(8b, 91b)
88f36bbf21SChristophe Leroy	EX_TABLE(9b, 91b)
89f36bbf21SChristophe Leroy
9061e3acd8SAndrew DonnellanEXPORT_SYMBOL(__arch_clear_user)
91