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