blob: b9e790b9c6b8c41356883593f3e70e81ea2733c7 [file] [log] [blame]
David S. Miller8591e302006-02-07 16:09:12 -08001/* NGpage.S: Niagara optimize clear and copy page.
2 *
3 * Copyright (C) 2006 (davem@davemloft.net)
4 */
5
6#include <asm/asi.h>
7#include <asm/page.h>
8
9 .text
10 .align 32
11
12 /* This is heavily simplified from the sun4u variants
13 * because Niagara does not have any D-cache aliasing issues
14 * and also we don't need to use the FPU in order to implement
15 * an optimal page copy/clear.
16 */
17
18NGcopy_user_page: /* %o0=dest, %o1=src, %o2=vaddr */
David S. Millere95ade02011-08-01 18:18:57 -070019 save %sp, -192, %sp
20 rd %asi, %g3
21 wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi
David S. Miller8591e302006-02-07 16:09:12 -080022 set PAGE_SIZE, %g7
David S. Millere95ade02011-08-01 18:18:57 -070023 prefetch [%i1 + 0x00], #one_read
24 prefetch [%i1 + 0x40], #one_read
David S. Miller8591e302006-02-07 16:09:12 -080025
David S. Millere95ade02011-08-01 18:18:57 -0700261: prefetch [%i1 + 0x80], #one_read
27 prefetch [%i1 + 0xc0], #one_read
28 ldda [%i1 + 0x00] %asi, %o2
29 ldda [%i1 + 0x10] %asi, %o4
30 ldda [%i1 + 0x20] %asi, %l2
31 ldda [%i1 + 0x30] %asi, %l4
32 stxa %o2, [%i0 + 0x00] %asi
33 stxa %o3, [%i0 + 0x08] %asi
34 stxa %o4, [%i0 + 0x10] %asi
35 stxa %o5, [%i0 + 0x18] %asi
36 stxa %l2, [%i0 + 0x20] %asi
37 stxa %l3, [%i0 + 0x28] %asi
38 stxa %l4, [%i0 + 0x30] %asi
39 stxa %l5, [%i0 + 0x38] %asi
40 ldda [%i1 + 0x40] %asi, %o2
41 ldda [%i1 + 0x50] %asi, %o4
42 ldda [%i1 + 0x60] %asi, %l2
43 ldda [%i1 + 0x70] %asi, %l4
44 stxa %o2, [%i0 + 0x40] %asi
45 stxa %o3, [%i0 + 0x48] %asi
46 stxa %o4, [%i0 + 0x50] %asi
47 stxa %o5, [%i0 + 0x58] %asi
48 stxa %l2, [%i0 + 0x60] %asi
49 stxa %l3, [%i0 + 0x68] %asi
50 stxa %l4, [%i0 + 0x70] %asi
51 stxa %l5, [%i0 + 0x78] %asi
52 add %i1, 128, %i1
53 subcc %g7, 128, %g7
David S. Miller8591e302006-02-07 16:09:12 -080054 bne,pt %xcc, 1b
David S. Millere95ade02011-08-01 18:18:57 -070055 add %i0, 128, %i0
56 wr %g3, 0x0, %asi
David S. Miller24d559c2007-03-19 13:27:33 -070057 membar #Sync
David S. Millere95ade02011-08-01 18:18:57 -070058 ret
59 restore
David S. Miller8591e302006-02-07 16:09:12 -080060
David S. Millere95ade02011-08-01 18:18:57 -070061 .align 32
David S. Miller8591e302006-02-07 16:09:12 -080062NGclear_page: /* %o0=dest */
63NGclear_user_page: /* %o0=dest, %o1=vaddr */
David S. Millere95ade02011-08-01 18:18:57 -070064 rd %asi, %g3
65 wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi
David S. Miller8591e302006-02-07 16:09:12 -080066 set PAGE_SIZE, %g7
67
David S. Millere95ade02011-08-01 18:18:57 -0700681: stxa %g0, [%o0 + 0x00] %asi
69 stxa %g0, [%o0 + 0x08] %asi
70 stxa %g0, [%o0 + 0x10] %asi
71 stxa %g0, [%o0 + 0x18] %asi
72 stxa %g0, [%o0 + 0x20] %asi
73 stxa %g0, [%o0 + 0x28] %asi
74 stxa %g0, [%o0 + 0x30] %asi
75 stxa %g0, [%o0 + 0x38] %asi
76 stxa %g0, [%o0 + 0x40] %asi
77 stxa %g0, [%o0 + 0x48] %asi
78 stxa %g0, [%o0 + 0x50] %asi
79 stxa %g0, [%o0 + 0x58] %asi
80 stxa %g0, [%o0 + 0x60] %asi
81 stxa %g0, [%o0 + 0x68] %asi
82 stxa %g0, [%o0 + 0x70] %asi
83 stxa %g0, [%o0 + 0x78] %asi
84 stxa %g0, [%o0 + 0x80] %asi
85 stxa %g0, [%o0 + 0x88] %asi
86 stxa %g0, [%o0 + 0x90] %asi
87 stxa %g0, [%o0 + 0x98] %asi
88 stxa %g0, [%o0 + 0xa0] %asi
89 stxa %g0, [%o0 + 0xa8] %asi
90 stxa %g0, [%o0 + 0xb0] %asi
91 stxa %g0, [%o0 + 0xb8] %asi
92 stxa %g0, [%o0 + 0xc0] %asi
93 stxa %g0, [%o0 + 0xc8] %asi
94 stxa %g0, [%o0 + 0xd0] %asi
95 stxa %g0, [%o0 + 0xd8] %asi
96 stxa %g0, [%o0 + 0xe0] %asi
97 stxa %g0, [%o0 + 0xe8] %asi
98 stxa %g0, [%o0 + 0xf0] %asi
99 stxa %g0, [%o0 + 0xf8] %asi
100 subcc %g7, 256, %g7
David S. Miller8591e302006-02-07 16:09:12 -0800101 bne,pt %xcc, 1b
David S. Millere95ade02011-08-01 18:18:57 -0700102 add %o0, 256, %o0
103 wr %g3, 0x0, %asi
David S. Miller24d559c2007-03-19 13:27:33 -0700104 membar #Sync
David S. Miller8591e302006-02-07 16:09:12 -0800105 retl
106 nop
107
108#define BRANCH_ALWAYS 0x10680000
109#define NOP 0x01000000
110#define NG_DO_PATCH(OLD, NEW) \
111 sethi %hi(NEW), %g1; \
112 or %g1, %lo(NEW), %g1; \
113 sethi %hi(OLD), %g2; \
114 or %g2, %lo(OLD), %g2; \
115 sub %g1, %g2, %g1; \
116 sethi %hi(BRANCH_ALWAYS), %g3; \
David S. Miller6241e5c2006-02-11 23:28:40 -0800117 sll %g1, 11, %g1; \
118 srl %g1, 11 + 2, %g1; \
David S. Miller8591e302006-02-07 16:09:12 -0800119 or %g3, %lo(BRANCH_ALWAYS), %g3; \
120 or %g3, %g1, %g3; \
121 stw %g3, [%g2]; \
122 sethi %hi(NOP), %g3; \
123 or %g3, %lo(NOP), %g3; \
124 stw %g3, [%g2 + 0x4]; \
125 flush %g2;
126
127 .globl niagara_patch_pageops
128 .type niagara_patch_pageops,#function
129niagara_patch_pageops:
130 NG_DO_PATCH(copy_user_page, NGcopy_user_page)
131 NG_DO_PATCH(_clear_page, NGclear_page)
132 NG_DO_PATCH(clear_user_page, NGclear_user_page)
133 retl
134 nop
135 .size niagara_patch_pageops,.-niagara_patch_pageops