xref: /openbmc/linux/arch/powerpc/lib/copypage_64.S (revision 7a846d3c43b0b6d04300be9ba666b102b57a391a)
1/*
2 * Copyright (C) 2008 Mark Nelson, IBM Corp.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9#include <asm/page.h>
10#include <asm/processor.h>
11#include <asm/ppc_asm.h>
12#include <asm/asm-offsets.h>
13#include <asm/export.h>
14
15        .section        ".toc","aw"
16PPC64_CACHES:
17        .tc             ppc64_caches[TC],ppc64_caches
18        .section        ".text"
19
20_GLOBAL_TOC(copy_page)
21BEGIN_FTR_SECTION
22	lis	r5,PAGE_SIZE@h
23FTR_SECTION_ELSE
24#ifdef CONFIG_PPC_BOOK3S_64
25	b	copypage_power7
26#endif
27ALT_FTR_SECTION_END_IFCLR(CPU_FTR_VMX_COPY)
28	ori	r5,r5,PAGE_SIZE@l
29BEGIN_FTR_SECTION
30	ld      r10,PPC64_CACHES@toc(r2)
31	lwz	r11,DCACHEL1LOGBLOCKSIZE(r10)	/* log2 of cache block size */
32	lwz     r12,DCACHEL1BLOCKSIZE(r10)	/* get cache block size */
33	li	r9,0
34	srd	r8,r5,r11
35
36	mtctr	r8
37.Lsetup:
38	dcbt	r9,r4
39	dcbz	r9,r3
40	add	r9,r9,r12
41	bdnz	.Lsetup
42END_FTR_SECTION_IFSET(CPU_FTR_CP_USE_DCBTZ)
43	addi	r3,r3,-8
44	srdi    r8,r5,7		/* page is copied in 128 byte strides */
45	addi	r8,r8,-1	/* one stride copied outside loop */
46
47	mtctr	r8
48
49	ld	r5,0(r4)
50	ld	r6,8(r4)
51	ld	r7,16(r4)
52	ldu	r8,24(r4)
531:	std	r5,8(r3)
54	std	r6,16(r3)
55	ld	r9,8(r4)
56	ld	r10,16(r4)
57	std	r7,24(r3)
58	std	r8,32(r3)
59	ld	r11,24(r4)
60	ld	r12,32(r4)
61	std	r9,40(r3)
62	std	r10,48(r3)
63	ld	r5,40(r4)
64	ld	r6,48(r4)
65	std	r11,56(r3)
66	std	r12,64(r3)
67	ld	r7,56(r4)
68	ld	r8,64(r4)
69	std	r5,72(r3)
70	std	r6,80(r3)
71	ld	r9,72(r4)
72	ld	r10,80(r4)
73	std	r7,88(r3)
74	std	r8,96(r3)
75	ld	r11,88(r4)
76	ld	r12,96(r4)
77	std	r9,104(r3)
78	std	r10,112(r3)
79	ld	r5,104(r4)
80	ld	r6,112(r4)
81	std	r11,120(r3)
82	stdu	r12,128(r3)
83	ld	r7,120(r4)
84	ldu	r8,128(r4)
85	bdnz	1b
86
87	std	r5,8(r3)
88	std	r6,16(r3)
89	ld	r9,8(r4)
90	ld	r10,16(r4)
91	std	r7,24(r3)
92	std	r8,32(r3)
93	ld	r11,24(r4)
94	ld	r12,32(r4)
95	std	r9,40(r3)
96	std	r10,48(r3)
97	ld	r5,40(r4)
98	ld	r6,48(r4)
99	std	r11,56(r3)
100	std	r12,64(r3)
101	ld	r7,56(r4)
102	ld	r8,64(r4)
103	std	r5,72(r3)
104	std	r6,80(r3)
105	ld	r9,72(r4)
106	ld	r10,80(r4)
107	std	r7,88(r3)
108	std	r8,96(r3)
109	ld	r11,88(r4)
110	ld	r12,96(r4)
111	std	r9,104(r3)
112	std	r10,112(r3)
113	std	r11,120(r3)
114	std	r12,128(r3)
115	blr
116EXPORT_SYMBOL(copy_page)
117