1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#pragma ident	"%Z%%M%	%I%	%E% SMI"
28
29#if defined(__lint)
30#include <kmdb/kmdb_asmutil.h>
31#endif
32
33#include <sys/asm_linkage.h>
34
35#if defined(__lint)
36/*ARGSUSED*/
37uintptr_t
38cas(uintptr_t *rs1, uintptr_t rs2, uintptr_t rd)
39{
40	return (0);
41}
42#else
43
44	ENTRY_NP(cas)
45	movq	%rsi, %rax
46	lock
47	  cmpxchgq %rdx, (%rdi)
48	ret
49	SET_SIZE(cas)
50#endif
51
52#if defined(__lint)
53void
54membar_producer(void)
55{
56}
57#else
58
59	ENTRY(membar_producer)
60	sfence
61	ret
62	SET_SIZE(membar_producer)
63
64#endif
65
66#if defined(__lint)
67/*ARGSUSED*/
68void
69rdmsr(uint32_t addr, uint64_t *retp)
70{
71}
72#else
73
74	ENTRY(rdmsr)
75	movl	%edi, %ecx
76	rdmsr
77	movl	%eax, (%rsi)
78	movl	%edx, 4(%rsi)
79	ret
80	SET_SIZE(rdmsr)
81
82#endif
83
84#if defined(__lint)
85/*ARGSUSED*/
86void
87wrmsr(uint32_t addr, uint64_t *valp)
88{
89}
90#else
91
92	ENTRY(wrmsr)
93	movl	(%rsi), %eax
94	movl	4(%rsi), %edx
95	movl	%edi, %ecx
96	wrmsr
97	ret
98	SET_SIZE(wrmsr)
99
100#endif
101
102#if defined(__lint)
103uintptr_t
104get_fp(void)
105{
106	return (0);
107}
108#else
109
110	ENTRY(get_fp)
111	movq	%rbp, %rax
112	ret
113	SET_SIZE(get_fp)
114
115#endif
116
117#if defined(__lint)
118/*ARGSUSED*/
119void
120kmt_in(void *buf, size_t nbytes, uintptr_t addr)
121{
122}
123
124/*ARGSUSED*/
125void
126kmt_out(void *buf, size_t nbytes, uintptr_t addr)
127{
128}
129#else
130
131	ENTRY_NP(kmt_in)
132	cmpq	$4, %rsi
133	je	4f
134	cmpq	$2, %rsi
135	je	2f
136
1371:	inb	(%dx)
138	movb	%al, 0(%rdi)
139	ret
140
1412:	inw	(%dx)
142	movw	%ax, 0(%rdi)
143	ret
144
1454:	inl	(%dx)
146	movl	%eax, 0(%rdi)
147	ret
148	SET_SIZE(kmt_in)
149
150	ENTRY_NP(kmt_out)
151	cmpq	$4, %rsi
152	je	4f
153	cmpq	$2, %rsi
154	je	2f
155
1561:	movb	0(%rdi), %al
157	outb	(%dx)
158	ret
159
1602:	movw	0(%rdi), %ax
161	outw	(%dx)
162	ret
163
1644:	movl	0(%rdi), %eax
165	outl	(%dx)
166	ret
167	SET_SIZE(kmt_out)
168
169#endif
170