Home | History | Annotate | Line # | Download | only in libnvmm
h_mem_assist_asm.S revision 1.1.2.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 	.text
     40 	.code64
     41 
     42 #define TEST_END	\
     43 	movq	$0xFFFFFFFFFFFFFFFF,%rcx;	\
     44 	rdmsr	;
     45 
     46 	.align	64
     47 test1_begin:
     48 	movq	$0x1000,%rax
     49 	movq	$0x1000,%rbp
     50 
     51 	movq	$0x1000,(%rax)
     52 
     53 	movq	$1,%r11
     54 	movq	$0x2000,(%rax,%r11,8)
     55 
     56 	movq	(%rbp),%r8
     57 	movq	8(%rbp),%rbx
     58 	addq	%rbx,%r8
     59 	movq	%r8,(%rbp)
     60 	movb	$4,(%rbp)
     61 
     62 	TEST_END
     63 test1_end:
     64 
     65 	.align	64
     66 test2_begin:
     67 	movq	$0x1000,%rax
     68 
     69 	movq	$0x1000,(%rax)
     70 	movq	$0x00FF,%rbx
     71 	orb	%bl,(%rax)
     72 	movq	$0x0400,%rcx
     73 	orw	%cx,(%rax)
     74 
     75 	TEST_END
     76 test2_end:
     77 
     78 	.align	64
     79 test3_begin:
     80 	movq	$0x1000,%rax
     81 
     82 	movq	$0x1FFF,(%rax)
     83 	movq	$0x1FF0,%rbx
     84 	andq	%rbx,(%rax)
     85 	movq	$0x10C1,%rcx
     86 	andb	%cl,(%rax)
     87 
     88 	TEST_END
     89 test3_end:
     90 
     91 	.align	64
     92 test4_begin:
     93 	movq	$0x1000,%rax
     94 
     95 	movq	$0x1FFF,(%rax)
     96 	movq	$0x1FF0,%rbx
     97 	xorq	%rbx,(%rax)
     98 	movq	$0x10C0,%rcx
     99 	xorw	%cx,(%rax)
    100 
    101 	TEST_END
    102 test4_end:
    103 
    104 	.align	64
    105 test5_begin:
    106 	movq	$0xFFFFFFFF00001000,%rax
    107 
    108 	movq	$0x1FFF,(%eax)
    109 	movb	$0,(%eax,%ebx,1)
    110 
    111 	TEST_END
    112 test5_end:
    113 
    114 	.align	64
    115 test6_begin:
    116 	movq	$0xFFA0,%rax
    117 	movabs	%rax,0x1000
    118 
    119 	movabs	0x1000,%al
    120 	orb	$0x0B,%al
    121 	movabs	%al,0x1000
    122 
    123 	TEST_END
    124 test6_end:
    125 
    126 	.align	64
    127 test7_begin:
    128 	movq	$0x56,%rax
    129 
    130 	movq	$1,%rcx
    131 	movq	$0x1000,%rdi
    132 	rep	stosb
    133 
    134 	movq	$0x1234,%rax
    135 	stosw
    136 
    137 	TEST_END
    138 test7_end:
    139 
    140 	.align	64
    141 test8_begin:
    142 	movq	$0x1008,%rsi
    143 	movq	$0x12345678,(%rsi)
    144 
    145 	movq	$0x1000,%rdi
    146 
    147 	lodsw
    148 	movw	%ax,(%rdi)
    149 	addq	$2,%rdi
    150 
    151 	lodsb
    152 	movb	%al,(%rdi)
    153 	addq	$1,%rdi
    154 
    155 	lodsb
    156 	movb	%al,(%rdi)
    157 	addq	$2,%rdi
    158 
    159 	TEST_END
    160 test8_end:
    161 
    162 	.align	64
    163 test9_begin:
    164 	movq	$0x1000,%rax
    165 
    166 	movq	$0x12345678,8(%rax)
    167 
    168 	movq	$0x1008,%rsi
    169 	movq	$0x1000,%rdi
    170 
    171 	movq	$4,%rcx
    172 	rep movsb
    173 
    174 	movq	$2,%rcx
    175 	rep movsw
    176 
    177 	TEST_END
    178 test9_end:
    179 
    180