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