1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* NGpage.S: Niagara optimize clear and copy page.
4 * Copyright (C) 2006 (davem@davemloft.net)
13 /* This is heavily simplified from the sun4u variants
14 * because Niagara does not have any D-cache aliasing issues
15 * and also we don't need to use the FPU in order to implement
16 * an optimal page copy/clear.
19 NGcopy_user_page: /* %o0=dest, %o1=src, %o2=vaddr */
22 wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi
24 prefetch [%i1 + 0x00], #one_read
25 prefetch [%i1 + 0x40], #one_read
27 1: prefetch [%i1 + 0x80], #one_read
28 prefetch [%i1 + 0xc0], #one_read
29 ldda [%i1 + 0x00] %asi, %o2
30 ldda [%i1 + 0x10] %asi, %o4
31 ldda [%i1 + 0x20] %asi, %l2
32 ldda [%i1 + 0x30] %asi, %l4
33 stxa %o2, [%i0 + 0x00] %asi
34 stxa %o3, [%i0 + 0x08] %asi
35 stxa %o4, [%i0 + 0x10] %asi
36 stxa %o5, [%i0 + 0x18] %asi
37 stxa %l2, [%i0 + 0x20] %asi
38 stxa %l3, [%i0 + 0x28] %asi
39 stxa %l4, [%i0 + 0x30] %asi
40 stxa %l5, [%i0 + 0x38] %asi
41 ldda [%i1 + 0x40] %asi, %o2
42 ldda [%i1 + 0x50] %asi, %o4
43 ldda [%i1 + 0x60] %asi, %l2
44 ldda [%i1 + 0x70] %asi, %l4
45 stxa %o2, [%i0 + 0x40] %asi
46 stxa %o3, [%i0 + 0x48] %asi
47 stxa %o4, [%i0 + 0x50] %asi
48 stxa %o5, [%i0 + 0x58] %asi
49 stxa %l2, [%i0 + 0x60] %asi
50 stxa %l3, [%i0 + 0x68] %asi
51 stxa %l4, [%i0 + 0x70] %asi
52 stxa %l5, [%i0 + 0x78] %asi
64 .globl NGclear_user_page
65 NGclear_page: /* %o0=dest */
66 NGclear_user_page: /* %o0=dest, %o1=vaddr */
68 wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi
71 1: stxa %g0, [%o0 + 0x00] %asi
72 stxa %g0, [%o0 + 0x08] %asi
73 stxa %g0, [%o0 + 0x10] %asi
74 stxa %g0, [%o0 + 0x18] %asi
75 stxa %g0, [%o0 + 0x20] %asi
76 stxa %g0, [%o0 + 0x28] %asi
77 stxa %g0, [%o0 + 0x30] %asi
78 stxa %g0, [%o0 + 0x38] %asi
79 stxa %g0, [%o0 + 0x40] %asi
80 stxa %g0, [%o0 + 0x48] %asi
81 stxa %g0, [%o0 + 0x50] %asi
82 stxa %g0, [%o0 + 0x58] %asi
83 stxa %g0, [%o0 + 0x60] %asi
84 stxa %g0, [%o0 + 0x68] %asi
85 stxa %g0, [%o0 + 0x70] %asi
86 stxa %g0, [%o0 + 0x78] %asi
87 stxa %g0, [%o0 + 0x80] %asi
88 stxa %g0, [%o0 + 0x88] %asi
89 stxa %g0, [%o0 + 0x90] %asi
90 stxa %g0, [%o0 + 0x98] %asi
91 stxa %g0, [%o0 + 0xa0] %asi
92 stxa %g0, [%o0 + 0xa8] %asi
93 stxa %g0, [%o0 + 0xb0] %asi
94 stxa %g0, [%o0 + 0xb8] %asi
95 stxa %g0, [%o0 + 0xc0] %asi
96 stxa %g0, [%o0 + 0xc8] %asi
97 stxa %g0, [%o0 + 0xd0] %asi
98 stxa %g0, [%o0 + 0xd8] %asi
99 stxa %g0, [%o0 + 0xe0] %asi
100 stxa %g0, [%o0 + 0xe8] %asi
101 stxa %g0, [%o0 + 0xf0] %asi
102 stxa %g0, [%o0 + 0xf8] %asi
111 #define BRANCH_ALWAYS 0x10680000
112 #define NOP 0x01000000
113 #define NG_DO_PATCH(OLD, NEW) \
114 sethi %hi(NEW), %g1; \
115 or %g1, %lo(NEW), %g1; \
116 sethi %hi(OLD), %g2; \
117 or %g2, %lo(OLD), %g2; \
119 sethi %hi(BRANCH_ALWAYS), %g3; \
121 srl %g1, 11 + 2, %g1; \
122 or %g3, %lo(BRANCH_ALWAYS), %g3; \
125 sethi %hi(NOP), %g3; \
126 or %g3, %lo(NOP), %g3; \
127 stw %g3, [%g2 + 0x4]; \
130 .globl niagara_patch_pageops
131 .type niagara_patch_pageops,#function
132 niagara_patch_pageops:
133 NG_DO_PATCH(copy_user_page, NGcopy_user_page)
134 NG_DO_PATCH(_clear_page, NGclear_page)
135 NG_DO_PATCH(clear_user_page, NGclear_user_page)
138 .size niagara_patch_pageops,.-niagara_patch_pageops