17c478bd9Sstevel@tonic-gate/*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
54ab75253Smrj * Common Development and Distribution License (the "License").
64ab75253Smrj * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
214ab75253Smrj
227c478bd9Sstevel@tonic-gate/*
2385641879Skalai * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
2765f20420SRobert Mustacchi/*
2865f20420SRobert Mustacchi * Copyright 2019 Joyent, Inc.
2965f20420SRobert Mustacchi */
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h>
327c478bd9Sstevel@tonic-gate#include <sys/asm_misc.h>
337c478bd9Sstevel@tonic-gate#include "assym.h"
347c478bd9Sstevel@tonic-gate
354ab75253Smrj	ENTRY(ddi_get8)
364ab75253Smrj	ALTENTRY(ddi_getb)
377c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_getb)
387c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_get8)
397c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_io_getb)
407c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_io_get8)
417c478bd9Sstevel@tonic-gate	movl	ACC_ATTR(%rdi), %edx
427c478bd9Sstevel@tonic-gate	cmpl	$_CONST(DDI_ACCATTR_IO_SPACE|DDI_ACCATTR_DIRECT), %edx
437c478bd9Sstevel@tonic-gate	jne	1f
447c478bd9Sstevel@tonic-gate	movq	%rsi, %rdx
457c478bd9Sstevel@tonic-gate	xorq	%rax, %rax
467c478bd9Sstevel@tonic-gate	inb	(%dx)
477c478bd9Sstevel@tonic-gate	ret
487c478bd9Sstevel@tonic-gate1:
497c478bd9Sstevel@tonic-gate	cmpl	$_CONST(DDI_ACCATTR_CPU_VADDR|DDI_ACCATTR_DIRECT), %edx
507c478bd9Sstevel@tonic-gate	jne	2f
517c478bd9Sstevel@tonic-gate	movzbq	(%rsi), %rax
527c478bd9Sstevel@tonic-gate	ret
537c478bd9Sstevel@tonic-gate2:
5465f20420SRobert Mustacchi	movq	ACC_GETB(%rdi), %rax
5565f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
567c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_get8)
574ab75253Smrj	SET_SIZE(ddi_getb)
587c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_getb)
597c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_get8)
607c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_io_getb)
617c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_io_get8)
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate
644ab75253Smrj	ENTRY(ddi_get16)
654ab75253Smrj	ALTENTRY(ddi_getw)
667c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_getw)
677c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_get16)
687c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_io_getw)
697c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_io_get16)
707c478bd9Sstevel@tonic-gate	movl	ACC_ATTR(%rdi), %edx
717c478bd9Sstevel@tonic-gate	cmpl	$_CONST(DDI_ACCATTR_IO_SPACE|DDI_ACCATTR_DIRECT), %edx
727c478bd9Sstevel@tonic-gate	jne	3f
737c478bd9Sstevel@tonic-gate	movq	%rsi, %rdx
747c478bd9Sstevel@tonic-gate	xorq	%rax, %rax
757c478bd9Sstevel@tonic-gate	inw	(%dx)
767c478bd9Sstevel@tonic-gate	ret
777c478bd9Sstevel@tonic-gate3:
787c478bd9Sstevel@tonic-gate	cmpl	$_CONST(DDI_ACCATTR_CPU_VADDR|DDI_ACCATTR_DIRECT), %edx
797c478bd9Sstevel@tonic-gate	jne	4f
807c478bd9Sstevel@tonic-gate	movzwq	(%rsi), %rax
817c478bd9Sstevel@tonic-gate	ret
827c478bd9Sstevel@tonic-gate4:
8365f20420SRobert Mustacchi	movq	ACC_GETW(%rdi), %rax
8465f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
857c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_get16)
864ab75253Smrj	SET_SIZE(ddi_getw)
877c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_getw)
887c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_get16)
897c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_io_getw)
907c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_io_get16)
917c478bd9Sstevel@tonic-gate
927c478bd9Sstevel@tonic-gate
934ab75253Smrj	ENTRY(ddi_get32)
944ab75253Smrj	ALTENTRY(ddi_getl)
957c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_getl)
967c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_get32)
977c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_io_getl)
987c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_io_get32)
997c478bd9Sstevel@tonic-gate	movl	ACC_ATTR(%rdi), %edx
1007c478bd9Sstevel@tonic-gate	cmpl	$_CONST(DDI_ACCATTR_IO_SPACE|DDI_ACCATTR_DIRECT), %edx
1017c478bd9Sstevel@tonic-gate	jne	5f
1027c478bd9Sstevel@tonic-gate	movq	%rsi, %rdx
1037c478bd9Sstevel@tonic-gate	inl	(%dx)
1047c478bd9Sstevel@tonic-gate	ret
1057c478bd9Sstevel@tonic-gate5:
1067c478bd9Sstevel@tonic-gate	cmpl	$_CONST(DDI_ACCATTR_CPU_VADDR|DDI_ACCATTR_DIRECT), %edx
1077c478bd9Sstevel@tonic-gate	jne	6f
1087c478bd9Sstevel@tonic-gate	movl	(%rsi), %eax
1097c478bd9Sstevel@tonic-gate	ret
1107c478bd9Sstevel@tonic-gate6:
11165f20420SRobert Mustacchi	movq	ACC_GETL(%rdi), %rax
11265f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
1137c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_get32)
1144ab75253Smrj	SET_SIZE(ddi_getl)
1157c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_getl)
1167c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_get32)
1177c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_io_getl)
1187c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_io_get32)
1197c478bd9Sstevel@tonic-gate
1207c478bd9Sstevel@tonic-gate
1214ab75253Smrj	ENTRY(ddi_get64)
1224ab75253Smrj	ALTENTRY(ddi_getll)
1237c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_getll)
1247c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_get64)
12565f20420SRobert Mustacchi	movq	ACC_GETLL(%rdi), %rax
12665f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
1277c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_get64)
1284ab75253Smrj	SET_SIZE(ddi_getll)
1297c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_getll)
1307c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_get64)
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gate
1334ab75253Smrj	ENTRY(ddi_put8)
1344ab75253Smrj	ALTENTRY(ddi_putb)
1357c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_putb)
1367c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_put8)
1377c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_io_putb)
1387c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_io_put8)
1397c478bd9Sstevel@tonic-gate	movl	ACC_ATTR(%rdi), %ecx
1407c478bd9Sstevel@tonic-gate	cmpl	$_CONST(DDI_ACCATTR_IO_SPACE|DDI_ACCATTR_DIRECT), %ecx
1417c478bd9Sstevel@tonic-gate	jne	7f
1427c478bd9Sstevel@tonic-gate	movq	%rdx, %rax
1437c478bd9Sstevel@tonic-gate	movq	%rsi, %rdx
1447c478bd9Sstevel@tonic-gate	outb	(%dx)
1457c478bd9Sstevel@tonic-gate	ret
1467c478bd9Sstevel@tonic-gate7:
1477c478bd9Sstevel@tonic-gate	cmpl	$_CONST(DDI_ACCATTR_CPU_VADDR|DDI_ACCATTR_DIRECT), %ecx
1487c478bd9Sstevel@tonic-gate	jne	8f
1497c478bd9Sstevel@tonic-gate	movb	%dl, (%rsi)
1507c478bd9Sstevel@tonic-gate	ret
1517c478bd9Sstevel@tonic-gate8:
15265f20420SRobert Mustacchi	movq	ACC_PUTB(%rdi), %rax
15365f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
1547c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_put8)
1554ab75253Smrj	SET_SIZE(ddi_putb)
1567c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_putb)
1577c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_put8)
1587c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_io_putb)
1597c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_io_put8)
1607c478bd9Sstevel@tonic-gate
1617c478bd9Sstevel@tonic-gate
1624ab75253Smrj	ENTRY(ddi_put16)
1634ab75253Smrj	ALTENTRY(ddi_putw)
1647c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_putw)
1657c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_put16)
1667c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_io_putw)
1677c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_io_put16)
1687c478bd9Sstevel@tonic-gate	movl	ACC_ATTR(%rdi), %ecx
1697c478bd9Sstevel@tonic-gate	cmpl	$_CONST(DDI_ACCATTR_IO_SPACE|DDI_ACCATTR_DIRECT), %ecx
1707c478bd9Sstevel@tonic-gate	jne	8f
1717c478bd9Sstevel@tonic-gate	movq	%rdx, %rax
1727c478bd9Sstevel@tonic-gate	movq	%rsi, %rdx
1737c478bd9Sstevel@tonic-gate	outw	(%dx)
1747c478bd9Sstevel@tonic-gate	ret
1757c478bd9Sstevel@tonic-gate8:
1767c478bd9Sstevel@tonic-gate	cmpl	$_CONST(DDI_ACCATTR_CPU_VADDR|DDI_ACCATTR_DIRECT), %ecx
1777c478bd9Sstevel@tonic-gate	jne	9f
1787c478bd9Sstevel@tonic-gate	movw	%dx, (%rsi)
1797c478bd9Sstevel@tonic-gate	ret
1807c478bd9Sstevel@tonic-gate9:
18165f20420SRobert Mustacchi	movq	ACC_PUTW(%rdi), %rax
18265f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
1837c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_put16)
1844ab75253Smrj	SET_SIZE(ddi_putw)
1857c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_putw)
1867c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_put16)
1877c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_io_putw)
1887c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_io_put16)
1897c478bd9Sstevel@tonic-gate
1907c478bd9Sstevel@tonic-gate
1914ab75253Smrj	ENTRY(ddi_put32)
1924ab75253Smrj	ALTENTRY(ddi_putl)
1937c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_putl)
1947c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_put32)
1957c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_io_putl)
1967c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_io_put32)
1977c478bd9Sstevel@tonic-gate	movl	ACC_ATTR(%rdi), %ecx
1987c478bd9Sstevel@tonic-gate	cmpl	$_CONST(DDI_ACCATTR_IO_SPACE|DDI_ACCATTR_DIRECT), %ecx
1997c478bd9Sstevel@tonic-gate	jne	8f
2007c478bd9Sstevel@tonic-gate	movq	%rdx, %rax
2017c478bd9Sstevel@tonic-gate	movq	%rsi, %rdx
2027c478bd9Sstevel@tonic-gate	outl	(%dx)
2037c478bd9Sstevel@tonic-gate	ret
2047c478bd9Sstevel@tonic-gate8:
2057c478bd9Sstevel@tonic-gate	cmpl	$_CONST(DDI_ACCATTR_CPU_VADDR|DDI_ACCATTR_DIRECT), %ecx
2067c478bd9Sstevel@tonic-gate	jne	9f
2077c478bd9Sstevel@tonic-gate	movl	%edx, (%rsi)
2087c478bd9Sstevel@tonic-gate	ret
2097c478bd9Sstevel@tonic-gate9:
21065f20420SRobert Mustacchi	movq	ACC_PUTL(%rdi), %rax
21165f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
2127c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_put32)
2134ab75253Smrj	SET_SIZE(ddi_putl)
2147c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_putl)
2157c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_put32)
2167c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_io_putl)
2177c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_io_put32)
2187c478bd9Sstevel@tonic-gate
2197c478bd9Sstevel@tonic-gate
2204ab75253Smrj	ENTRY(ddi_put64)
2214ab75253Smrj	ALTENTRY(ddi_putll)
2227c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_putll)
2237c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_put64)
22465f20420SRobert Mustacchi	movq	ACC_PUTLL(%rdi), %rax
22565f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
2267c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_put64)
2274ab75253Smrj	SET_SIZE(ddi_putll)
2287c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_putll)
2297c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_put64)
2307c478bd9Sstevel@tonic-gate
2317c478bd9Sstevel@tonic-gate
2324ab75253Smrj	ENTRY(ddi_rep_get8)
2334ab75253Smrj	ALTENTRY(ddi_rep_getb)
2347c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_getb)
2357c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_get8)
23665f20420SRobert Mustacchi	movq	ACC_REP_GETB(%rdi), %rax
23765f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
2387c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_rep_get8)
2394ab75253Smrj	SET_SIZE(ddi_rep_getb)
2407c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_getb)
2417c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_get8)
2427c478bd9Sstevel@tonic-gate
2437c478bd9Sstevel@tonic-gate
2444ab75253Smrj	ENTRY(ddi_rep_get16)
2454ab75253Smrj	ALTENTRY(ddi_rep_getw)
2467c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_getw)
2477c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_get16)
24865f20420SRobert Mustacchi	movq	ACC_REP_GETW(%rdi), %rax
24965f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
2507c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_rep_get16)
2514ab75253Smrj	SET_SIZE(ddi_rep_getw)
2527c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_getw)
2537c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_get16)
2547c478bd9Sstevel@tonic-gate
2557c478bd9Sstevel@tonic-gate
2564ab75253Smrj	ENTRY(ddi_rep_get32)
2574ab75253Smrj	ALTENTRY(ddi_rep_getl)
2587c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_getl)
2597c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_get32)
26065f20420SRobert Mustacchi	movq	ACC_REP_GETL(%rdi), %rax
26165f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
2627c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_rep_get32)
2634ab75253Smrj	SET_SIZE(ddi_rep_getl)
2647c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_getl)
2657c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_get32)
2667c478bd9Sstevel@tonic-gate
2677c478bd9Sstevel@tonic-gate
2684ab75253Smrj	ENTRY(ddi_rep_get64)
2694ab75253Smrj	ALTENTRY(ddi_rep_getll)
2707c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_getll)
2717c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_get64)
27265f20420SRobert Mustacchi	movq	ACC_REP_GETLL(%rdi), %rax
27365f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
2747c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_rep_get64)
2754ab75253Smrj	SET_SIZE(ddi_rep_getll)
2767c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_getll)
2777c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_get64)
2787c478bd9Sstevel@tonic-gate
2797c478bd9Sstevel@tonic-gate
2804ab75253Smrj	ENTRY(ddi_rep_put8)
2814ab75253Smrj	ALTENTRY(ddi_rep_putb)
2827c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_putb)
2837c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_put8)
28465f20420SRobert Mustacchi	movq	ACC_REP_PUTB(%rdi), %rax
28565f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
2867c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_rep_put8)
2874ab75253Smrj	SET_SIZE(ddi_rep_putb)
2887c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_putb)
2897c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_put8)
2907c478bd9Sstevel@tonic-gate
2917c478bd9Sstevel@tonic-gate
2924ab75253Smrj	ENTRY(ddi_rep_put16)
2934ab75253Smrj	ALTENTRY(ddi_rep_putw)
2947c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_putw)
2957c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_put16)
29665f20420SRobert Mustacchi	movq	ACC_REP_PUTW(%rdi), %rax
29765f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
2987c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_rep_put16)
2994ab75253Smrj	SET_SIZE(ddi_rep_putw)
3007c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_putw)
3017c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_put16)
3027c478bd9Sstevel@tonic-gate
3037c478bd9Sstevel@tonic-gate
3044ab75253Smrj	ENTRY(ddi_rep_put32)
3054ab75253Smrj	ALTENTRY(ddi_rep_putl)
3067c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_putl)
3077c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_put32)
30865f20420SRobert Mustacchi	movq	ACC_REP_PUTL(%rdi), %rax
30965f20420SRobert Mustacchi	INDIRECT_JMP_REG(rax)
3107c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_rep_put32)
3114ab75253Smrj	SET_SIZE(ddi_rep_putl)
3127c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_putl)
3137c478bd9Sstevel@tonic-gate	SET_SIZE(ddi_mem_rep_put32)
3147c478bd9Sstevel@tonic-gate
3157c478bd9Sstevel@tonic-gate
3164ab75253Smrj	ENTRY(ddi_rep_put64)
3174ab75253Smrj	ALTENTRY(ddi_rep_putll)
3187c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_putll)
3197c478bd9Sstevel@tonic-gate	ALTENTRY(ddi_mem_rep_put64)
32065f20420SRobert Mustacchi	movq	ACC_REP_PUTLL(%rdi), %rax
321*9b0bb795SJohn Levon	INDIRECT_JMP_REG(rax)
322*9b0bb795SJohn Levon	SET_SIZE(ddi_rep_put64)
323*9b0bb795SJohn Levon	SET_SIZE(ddi_rep_putll)
324*9b0bb795SJohn Levon	SET_SIZE(ddi_mem_rep_putll)
325*9b0bb795SJohn Levon	SET_SIZE(ddi_mem_rep_put64)
3267c478bd9Sstevel@tonic-gate
3277c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_vaddr_get8)
3287c478bd9Sstevel@tonic-gate	movzbq	(%rsi), %rax
3297c478bd9Sstevel@tonic-gate	ret
3307c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_vaddr_get8)
3317c478bd9Sstevel@tonic-gate
3327c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_vaddr_get16)
3337c478bd9Sstevel@tonic-gate	movzwq	(%rsi), %rax
3347c478bd9Sstevel@tonic-gate	ret
3357c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_vaddr_get16)
3367c478bd9Sstevel@tonic-gate
3377c478bd9Sstevel@tonic-gate
3387c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_vaddr_get32)
3397c478bd9Sstevel@tonic-gate	movl	(%rsi), %eax
3407c478bd9Sstevel@tonic-gate	ret
3417c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_vaddr_get32)
3427c478bd9Sstevel@tonic-gate
3437c478bd9Sstevel@tonic-gate
3447c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_vaddr_get64)
3457c478bd9Sstevel@tonic-gate	movq	(%rsi), %rax
3467c478bd9Sstevel@tonic-gate	ret
3477c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_vaddr_get64)
3487c478bd9Sstevel@tonic-gate
3497c478bd9Sstevel@tonic-gate
3507c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_io_get8)
3517c478bd9Sstevel@tonic-gate	movq	%rsi, %rdx
3527c478bd9Sstevel@tonic-gate	inb	(%dx)
3537c478bd9Sstevel@tonic-gate	movzbq	%al, %rax
3547c478bd9Sstevel@tonic-gate	ret
3557c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_io_get8)
3567c478bd9Sstevel@tonic-gate
3577c478bd9Sstevel@tonic-gate
3587c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_io_get16)
3597c478bd9Sstevel@tonic-gate	movq	%rsi, %rdx
3607c478bd9Sstevel@tonic-gate	inw	(%dx)
3617c478bd9Sstevel@tonic-gate	movzwq	%ax, %rax
3627c478bd9Sstevel@tonic-gate	ret
3637c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_io_get16)
3647c478bd9Sstevel@tonic-gate
3657c478bd9Sstevel@tonic-gate
3667c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_io_get32)
3677c478bd9Sstevel@tonic-gate	movq	%rsi, %rdx
3687c478bd9Sstevel@tonic-gate	inl	(%dx)
3697c478bd9Sstevel@tonic-gate	ret
3707c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_io_get32)
3717c478bd9Sstevel@tonic-gate
3727c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_vaddr_put8)
3737c478bd9Sstevel@tonic-gate	movb	%dl, (%rsi)
3747c478bd9Sstevel@tonic-gate	ret
3757c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_vaddr_put8)
3767c478bd9Sstevel@tonic-gate
3777c478bd9Sstevel@tonic-gate
3787c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_vaddr_put16)
3797c478bd9Sstevel@tonic-gate	movw	%dx, (%rsi)
3807c478bd9Sstevel@tonic-gate	ret
3817c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_vaddr_put16)
3827c478bd9Sstevel@tonic-gate
3837c478bd9Sstevel@tonic-gate
3847c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_vaddr_put32)
3857c478bd9Sstevel@tonic-gate	movl	%edx, (%rsi)
3867c478bd9Sstevel@tonic-gate	ret
3877c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_vaddr_put32)
3887c478bd9Sstevel@tonic-gate
3897c478bd9Sstevel@tonic-gate
3907c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_vaddr_put64)
3917c478bd9Sstevel@tonic-gate	movq	%rdx, (%rsi)
3927c478bd9Sstevel@tonic-gate	ret
3937c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_vaddr_put64)
3947c478bd9Sstevel@tonic-gate
3957c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_io_put8)
3967c478bd9Sstevel@tonic-gate	movq	%rdx, %rax
3977c478bd9Sstevel@tonic-gate	movq	%rsi, %rdx
3987c478bd9Sstevel@tonic-gate	outb	(%dx)
3997c478bd9Sstevel@tonic-gate	ret
4007c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_io_put8)
4017c478bd9Sstevel@tonic-gate
4027c478bd9Sstevel@tonic-gate
4037c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_io_put16)
4047c478bd9Sstevel@tonic-gate	movq	%rdx, %rax
4057c478bd9Sstevel@tonic-gate	movq	%rsi, %rdx
4067c478bd9Sstevel@tonic-gate	outw	(%dx)
4077c478bd9Sstevel@tonic-gate	ret
4087c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_io_put16)
4097c478bd9Sstevel@tonic-gate
4107c478bd9Sstevel@tonic-gate
4117c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_io_put32)
4127c478bd9Sstevel@tonic-gate	movq	%rdx, %rax
4137c478bd9Sstevel@tonic-gate	movq	%rsi, %rdx
4147c478bd9Sstevel@tonic-gate	outl	(%dx)
4157c478bd9Sstevel@tonic-gate	ret
4167c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_io_put32)
4177c478bd9Sstevel@tonic-gate
4187c478bd9Sstevel@tonic-gate	/*
4197c478bd9Sstevel@tonic-gate	 * Incoming arguments
4207c478bd9Sstevel@tonic-gate	 *
4217c478bd9Sstevel@tonic-gate	 * %rdi	: hdlp
4227c478bd9Sstevel@tonic-gate	 * %rsi	: host_addr
4237c478bd9Sstevel@tonic-gate	 * %rdx	: dev_addr
4247c478bd9Sstevel@tonic-gate	 * %rcx	: repcount
4257c478bd9Sstevel@tonic-gate	 * %r8	: flags
4267c478bd9Sstevel@tonic-gate	 *
4277c478bd9Sstevel@tonic-gate	 * This routine will destroy values in %rdx, %rsi, %rcx.
4287c478bd9Sstevel@tonic-gate	 */
4297c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_io_rep_get8)
4307c478bd9Sstevel@tonic-gate
4317c478bd9Sstevel@tonic-gate	cmpq	$DDI_DEV_AUTOINCR, %r8
4327c478bd9Sstevel@tonic-gate	je	gb_ioadv
4337c478bd9Sstevel@tonic-gate	movq	%rsi, %rdi
4347c478bd9Sstevel@tonic-gate	rep
4357c478bd9Sstevel@tonic-gate	insb
4367c478bd9Sstevel@tonic-gate	ret
4377c478bd9Sstevel@tonic-gate
4387c478bd9Sstevel@tonic-gategb_ioadv:
43965f20420SRobert Mustacchi	andq	%rcx, %rcx
4407c478bd9Sstevel@tonic-gate	jz	gb_ioadv_done
4417c478bd9Sstevel@tonic-gategb_ioadv2:
4427c478bd9Sstevel@tonic-gate	inb	(%dx)
4437c478bd9Sstevel@tonic-gate	movb	%al, (%rsi)
4447c478bd9Sstevel@tonic-gate	incq	%rdx
4457c478bd9Sstevel@tonic-gate	incq	%rsi
4467c478bd9Sstevel@tonic-gate	decq	%rcx
4477c478bd9Sstevel@tonic-gate	jg	gb_ioadv2
4487c478bd9Sstevel@tonic-gate
4497c478bd9Sstevel@tonic-gategb_ioadv_done:
45085641879Skalai	rep;	ret	/* use 2 byte return instruction when branch target */
45185641879Skalai			/* AMD Software Optimization Guide - Section 6.2 */
4527c478bd9Sstevel@tonic-gate
4537c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_io_rep_get8)
4547c478bd9Sstevel@tonic-gate
4557c478bd9Sstevel@tonic-gate
4567c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_io_rep_get16)
4577c478bd9Sstevel@tonic-gate
4587c478bd9Sstevel@tonic-gate	cmpq	$DDI_DEV_AUTOINCR, %r8
4597c478bd9Sstevel@tonic-gate	je	gw_ioadv
4607c478bd9Sstevel@tonic-gate
4617c478bd9Sstevel@tonic-gate	movq	%rsi, %rdi
46265f20420SRobert Mustacchi	rep
4637c478bd9Sstevel@tonic-gate	insw
4647c478bd9Sstevel@tonic-gate	ret
4657c478bd9Sstevel@tonic-gate
4667c478bd9Sstevel@tonic-gategw_ioadv:
4677c478bd9Sstevel@tonic-gate	andq	%rcx, %rcx
4687c478bd9Sstevel@tonic-gate	jz	gw_ioadv_done
4697c478bd9Sstevel@tonic-gategw_ioadv2:
4707c478bd9Sstevel@tonic-gate	inw	(%dx)
4717c478bd9Sstevel@tonic-gate	movw	%ax,(%rsi)
4727c478bd9Sstevel@tonic-gate	addq	$2, %rsi
4737c478bd9Sstevel@tonic-gate	addq	$2, %rdx
4747c478bd9Sstevel@tonic-gate	decq	%rcx
4757c478bd9Sstevel@tonic-gate	jg	gw_ioadv2
4767c478bd9Sstevel@tonic-gate
4777c478bd9Sstevel@tonic-gategw_ioadv_done:
47885641879Skalai	rep;	ret	/* use 2 byte return instruction when branch target */
47985641879Skalai			/* AMD Software Optimization Guide - Section 6.2 */
4807c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_io_rep_get16)
4817c478bd9Sstevel@tonic-gate
4827c478bd9Sstevel@tonic-gate
4837c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_io_rep_get32)
4847c478bd9Sstevel@tonic-gate
4857c478bd9Sstevel@tonic-gate	cmpq	$DDI_DEV_AUTOINCR, %r8
4867c478bd9Sstevel@tonic-gate	je	gl_ioadv
4877c478bd9Sstevel@tonic-gate
4887c478bd9Sstevel@tonic-gate	movq	%rsi, %rdi
48965f20420SRobert Mustacchi	rep
4907c478bd9Sstevel@tonic-gate	insl
4917c478bd9Sstevel@tonic-gate	ret
4927c478bd9Sstevel@tonic-gate
4937c478bd9Sstevel@tonic-gategl_ioadv:
4947c478bd9Sstevel@tonic-gate	andq	%rcx, %rcx
4957c478bd9Sstevel@tonic-gate	jz	gl_ioadv_done
4967c478bd9Sstevel@tonic-gategl_ioadv2:
4977c478bd9Sstevel@tonic-gate	inl	(%dx)
4987c478bd9Sstevel@tonic-gate	movl	%eax,(%rsi)
4997c478bd9Sstevel@tonic-gate	addq	$4, %rsi
5007c478bd9Sstevel@tonic-gate	addq	$4, %rdx
5017c478bd9Sstevel@tonic-gate	decq	%rcx
5027c478bd9Sstevel@tonic-gate	jg	gl_ioadv2
5037c478bd9Sstevel@tonic-gate
5047c478bd9Sstevel@tonic-gategl_ioadv_done:
50585641879Skalai	rep;	ret	/* use 2 byte return instruction when branch target */
50685641879Skalai			/* AMD Software Optimization Guide - Section 6.2 */
5077c478bd9Sstevel@tonic-gate
5087c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_io_rep_get32)
5097c478bd9Sstevel@tonic-gate
5107c478bd9Sstevel@tonic-gate	/*
5117c478bd9Sstevel@tonic-gate	 * Incoming arguments
5127c478bd9Sstevel@tonic-gate	 *
5137c478bd9Sstevel@tonic-gate	 * %rdi	: hdlp
5147c478bd9Sstevel@tonic-gate	 * %rsi	: host_addr
5157c478bd9Sstevel@tonic-gate	 * %rdx	: dev_addr
5167c478bd9Sstevel@tonic-gate	 * %rcx	: repcount
5177c478bd9Sstevel@tonic-gate	 * %r8	: flags
5187c478bd9Sstevel@tonic-gate	 *
5197c478bd9Sstevel@tonic-gate	 * This routine will destroy values in %rdx, %rsi, %rcx.
5207c478bd9Sstevel@tonic-gate	 */
5217c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_io_rep_put8)
5227c478bd9Sstevel@tonic-gate
5237c478bd9Sstevel@tonic-gate	cmpq	$DDI_DEV_AUTOINCR, %r8
5247c478bd9Sstevel@tonic-gate	je	pb_ioadv
5257c478bd9Sstevel@tonic-gate
5267c478bd9Sstevel@tonic-gate	movq	%rsi, %rdi
52765f20420SRobert Mustacchi	rep
5287c478bd9Sstevel@tonic-gate	outsb
5297c478bd9Sstevel@tonic-gate	ret
5307c478bd9Sstevel@tonic-gate
5317c478bd9Sstevel@tonic-gatepb_ioadv:
5327c478bd9Sstevel@tonic-gate	andq	%rcx, %rcx
5337c478bd9Sstevel@tonic-gate	jz	pb_ioadv_done
5347c478bd9Sstevel@tonic-gatepb_ioadv2:
5357c478bd9Sstevel@tonic-gate	movb	(%rsi), %al
5367c478bd9Sstevel@tonic-gate	outb	(%dx)
5377c478bd9Sstevel@tonic-gate	incq	%rsi
5387c478bd9Sstevel@tonic-gate	incq	%rdx
5397c478bd9Sstevel@tonic-gate	decq	%rcx
5407c478bd9Sstevel@tonic-gate	jg	pb_ioadv2
5417c478bd9Sstevel@tonic-gate
5427c478bd9Sstevel@tonic-gatepb_ioadv_done:
54385641879Skalai	rep;	ret	/* use 2 byte return instruction when branch target */
54485641879Skalai			/* AMD Software Optimization Guide - Section 6.2 */
5457c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_io_rep_put8)
5467c478bd9Sstevel@tonic-gate
5477c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_io_rep_put16)
5487c478bd9Sstevel@tonic-gate
5497c478bd9Sstevel@tonic-gate	cmpq	$DDI_DEV_AUTOINCR, %r8
5507c478bd9Sstevel@tonic-gate	je	pw_ioadv
5517c478bd9Sstevel@tonic-gate
5527c478bd9Sstevel@tonic-gate	movq	%rsi, %rdi
55365f20420SRobert Mustacchi	rep
5547c478bd9Sstevel@tonic-gate	outsw
5557c478bd9Sstevel@tonic-gate	ret
5567c478bd9Sstevel@tonic-gate
5577c478bd9Sstevel@tonic-gatepw_ioadv:
5587c478bd9Sstevel@tonic-gate	andq	%rcx, %rcx
5597c478bd9Sstevel@tonic-gate	jz	pw_ioadv_done
5607c478bd9Sstevel@tonic-gatepw_ioadv2:
5617c478bd9Sstevel@tonic-gate	movw	(%rsi), %ax
5627c478bd9Sstevel@tonic-gate	outw	(%dx)
5637c478bd9Sstevel@tonic-gate	addq	$2, %rsi
5647c478bd9Sstevel@tonic-gate	addq	$2, %rdx
5657c478bd9Sstevel@tonic-gate	decq	%rcx
5667c478bd9Sstevel@tonic-gate	jg	pw_ioadv2
5677c478bd9Sstevel@tonic-gate
5687c478bd9Sstevel@tonic-gatepw_ioadv_done:
56985641879Skalai	rep;	ret	/* use 2 byte return instruction when branch target */
57085641879Skalai			/* AMD Software Optimization Guide - Section 6.2 */
5717c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_io_rep_put16)
5727c478bd9Sstevel@tonic-gate
5737c478bd9Sstevel@tonic-gate
5747c478bd9Sstevel@tonic-gate	ENTRY(i_ddi_io_rep_put32)
5757c478bd9Sstevel@tonic-gate
5767c478bd9Sstevel@tonic-gate	cmpq	$DDI_DEV_AUTOINCR, %r8
5777c478bd9Sstevel@tonic-gate	je	pl_ioadv
5787c478bd9Sstevel@tonic-gate
5797c478bd9Sstevel@tonic-gate	movq	%rsi, %rdi
58065f20420SRobert Mustacchi	rep
5817c478bd9Sstevel@tonic-gate	outsl
5827c478bd9Sstevel@tonic-gate	ret
5837c478bd9Sstevel@tonic-gate
5847c478bd9Sstevel@tonic-gatepl_ioadv:
5857c478bd9Sstevel@tonic-gate	andq	%rcx, %rcx
5867c478bd9Sstevel@tonic-gate	jz	pl_ioadv_done
5877c478bd9Sstevel@tonic-gatepl_ioadv2:
5887c478bd9Sstevel@tonic-gate	movl	(%rsi), %eax
5897c478bd9Sstevel@tonic-gate	outl	(%dx)
5907c478bd9Sstevel@tonic-gate	addq	$4, %rsi
5917c478bd9Sstevel@tonic-gate	addq	$4, %rdx
5927c478bd9Sstevel@tonic-gate	decq	%rcx
5937c478bd9Sstevel@tonic-gate	jg	pl_ioadv2
5947c478bd9Sstevel@tonic-gate
5957c478bd9Sstevel@tonic-gatepl_ioadv_done:
59685641879Skalai	rep;	ret	/* use 2 byte return instruction when branch target */
59785641879Skalai			/* AMD Software Optimization Guide - Section 6.2 */
5987c478bd9Sstevel@tonic-gate	SET_SIZE(i_ddi_io_rep_put32)
5997c478bd9Sstevel@tonic-gate
600