h_mem_assist_asm.S revision 1.3 1 /*
2 * Copyright (c) 2018 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Maxime Villard.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 .globl test1_begin, test1_end
31 .globl test2_begin, test2_end
32 .globl test3_begin, test3_end
33 .globl test4_begin, test4_end
34 .globl test5_begin, test5_end
35 .globl test6_begin, test6_end
36 .globl test7_begin, test7_end
37 .globl test8_begin, test8_end
38 .globl test9_begin, test9_end
39 .globl test10_begin, test10_end
40 .globl test11_begin, test11_end
41 .text
42 .code64
43
44 #define TEST_END \
45 movq $0xFFFFFFFFFFFFFFFF,%rcx; \
46 rdmsr ;
47
48 .align 64
49 test1_begin:
50 movq $0x1000,%rax
51 movq $0x1000,%rbp
52
53 movq $0x1000,(%rax)
54
55 movq $1,%r11
56 movq $0x2000,(%rax,%r11,8)
57
58 movq (%rbp),%r8
59 movq 8(%rbp),%rbx
60 addq %rbx,%r8
61 movq %r8,(%rbp)
62 movb $4,(%rbp)
63
64 TEST_END
65 test1_end:
66
67 .align 64
68 test2_begin:
69 movq $0x1000,%rax
70
71 movq $0x1000,(%rax)
72 movq $0x00FF,%rbx
73 orb %bl,(%rax)
74 movq $0x0400,%rcx
75 orw %cx,(%rax)
76
77 TEST_END
78 test2_end:
79
80 .align 64
81 test3_begin:
82 movq $0x1000,%rax
83
84 movq $0x1FFF,(%rax)
85 movq $0x1FF0,%rbx
86 andq %rbx,(%rax)
87 movq $0x10C1,%rcx
88 andb %cl,(%rax)
89
90 TEST_END
91 test3_end:
92
93 .align 64
94 test4_begin:
95 movq $0x1000,%rax
96
97 movq $0x1FFF,(%rax)
98 movq $0x1FF0,%rbx
99 xorq %rbx,(%rax)
100 movq $0x10C0,%rcx
101 xorw %cx,(%rax)
102
103 TEST_END
104 test4_end:
105
106 .align 64
107 test5_begin:
108 movq $0xFFFFFFFF00001000,%rax
109
110 movq $0x1FFF,(%eax)
111 movb $0,(%eax,%ebx,1)
112
113 TEST_END
114 test5_end:
115
116 .align 64
117 test6_begin:
118 movq $0xFFA0,%rax
119 movabs %rax,0x1000
120
121 movabs 0x1000,%al
122 orb $0x0B,%al
123 movabs %al,0x1000
124
125 TEST_END
126 test6_end:
127
128 .align 64
129 test7_begin:
130 movq $0x56,%rax
131
132 movq $1,%rcx
133 movq $0x1000,%rdi
134 rep stosb
135
136 movq $0x1234,%rax
137 stosw
138
139 TEST_END
140 test7_end:
141
142 .align 64
143 test8_begin:
144 movq $0x1008,%rsi
145 movq $0x12345678,(%rsi)
146
147 movq $0x1000,%rdi
148
149 lodsw
150 movw %ax,(%rdi)
151 addq $2,%rdi
152
153 lodsb
154 movb %al,(%rdi)
155 addq $1,%rdi
156
157 lodsb
158 movb %al,(%rdi)
159 addq $2,%rdi
160
161 TEST_END
162 test8_end:
163
164 .align 64
165 test9_begin:
166 movq $0x1000,%rax
167
168 movq $0x12345678,8(%rax)
169
170 movq $0x1008,%rsi
171 movq $0x1000,%rdi
172
173 movq $4,%rcx
174 rep movsb
175
176 movq $2,%rcx
177 rep movsw
178
179 TEST_END
180 test9_end:
181
182 .align 64
183 test10_begin:
184 movq $0x1000,%rax
185 movq $0x12345678,(%rax)
186
187 movq $0xFFFFFFFFFFFFFFFF,%rbx
188 movzxb (%rax),%ebx
189 movq %rbx,(%rax)
190
191 TEST_END
192 test10_end:
193
194 .align 64
195 test11_begin:
196 movq $0x1000,%rax
197 movq $0x12345678,(%rax)
198
199 movq $0xFFFFFFFFFFFFFFFF,%rbx
200 movzxw (%rax),%rbx
201 movq %rbx,(%rax)
202
203 TEST_END
204 test11_end:
205