1/* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
12 * Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23#ifdef INLINE_ASM
24#define FUNCTION_START(f,n)	.inline f,n
25#define FUNCTION_END(f)		.end
26#else
27#define _ASM
28#include <sys/asm_linkage.h>
29#define FUNCTION_START(f,n)	ENTRY(f)
30#define FUNCTION_END(f)		retl; nop; SET_SIZE(f)
31#endif
32
33/* Converted from common/compiler.h gcc inline format to Sun cc inline
34 * format by Kenjiro Tsuji
35 *
36 *	The value 0x88 means ASI_PRIMARY_LITTLE.
37 *	The store or load to/from the address space will be done
38 *	as little-endian. In the original xrog code, the value
39 *	is defined as the macro ASI_PL.
40 *
41 *	In the original xorg code, "membar #StoreStore|#StoreLoad"
42 *	is directly implemented as an instruction "0x8143e00a".
43 *
44 */
45
46	FUNCTION_START(outb, 0)
47	stba	%o1, [%o0] 0x88
48	membar	#StoreStore|#StoreLoad
49	FUNCTION_END(outb)
50
51	FUNCTION_START(outw, 0)
52	stha	%o1, [%o0] 0x88
53	membar	#StoreStore|#StoreLoad
54	FUNCTION_END(outw)
55
56	FUNCTION_START(outl, 0)
57	sta	%o1, [%o0] 0x88
58	membar	#StoreStore|#StoreLoad
59	FUNCTION_END(outl)
60
61	FUNCTION_START(inb, 0)
62	lduba	[%o0] 0x88, %o0
63	FUNCTION_END(inb)
64
65	FUNCTION_START(inw, 0)
66	lduha	[%o0] 0x88, %o0
67	FUNCTION_END(inw)
68
69	FUNCTION_START(inl, 0)
70	lda	[%o0] 0x88, %o0
71	FUNCTION_END(inl)
72
73	FUNCTION_START(xf86ReadMmio8, 0)
74	lduba	[%o0 + %o1] 0x88, %o0
75	FUNCTION_END(xf86ReadMmio8)
76
77	FUNCTION_START(xf86ReadMmio16Be, 0)
78	lduh	[%o0 + %o1], %o0
79	FUNCTION_END(xf86ReadMmio16Be)
80
81	FUNCTION_START(xf86ReadMmio16Le, 0)
82	lduha	[%o0 + %o1] 0x88, %o0
83	FUNCTION_END(xf86ReadMmio16Le)
84
85	FUNCTION_START(xf86ReadMmio32Be, 0)
86	ld	[%o0 + %o1], %o0
87	FUNCTION_END(xf86ReadMmio32Be)
88
89	FUNCTION_START(xf86ReadMmio32Le, 0)
90	lda	[%o0 + %o1] 0x88, %o0
91	FUNCTION_END(xf86ReadMmio32Le)
92
93	FUNCTION_START(xf86WriteMmio8, 0)
94	stba	%o2, [%o0 + %o1] 0x88
95	membar	#StoreStore|#StoreLoad
96	FUNCTION_END(xf86WriteMmio8)
97
98	FUNCTION_START(xf86WriteMmio16Be, 0)
99	sth	%o2, [%o0 + %o1]
100	membar	#StoreStore|#StoreLoad
101	FUNCTION_END(xf86WriteMmio16Be)
102
103	FUNCTION_START(xf86WriteMmio16Le, 0)
104	stha	%o2, [%o0 + %o1] 0x88
105	membar	#StoreStore|#StoreLoad
106	FUNCTION_END(xf86WriteMmio16Le)
107
108	FUNCTION_START(xf86WriteMmio32Be, 0)
109	st	%o2, [%o0 + %o1]
110	membar	#StoreStore|#StoreLoad
111	FUNCTION_END(xf86WriteMmio32Be)
112
113	FUNCTION_START(xf86WriteMmio32Le, 0)
114	sta	%o2, [%o0 + %o1] 0x88
115	membar	#StoreStore|#StoreLoad
116	FUNCTION_END(xf86WriteMmio32Le)
117
118	FUNCTION_START(xf86WriteMmio8NB, 0)
119	add	%o0, %o1, %o0
120	stba	%o2, [%o0] 0x88
121	FUNCTION_END(xf86WriteMmio8NB)
122
123	FUNCTION_START(xf86WriteMmio16BeNB, 0)
124	sth	%o2, [%o0 + %o1]
125	FUNCTION_END(xf86WriteMmio16BeNB)
126
127	FUNCTION_START(xf86WriteMmio16LeNB, 0)
128	stha	%o2, [%o0 + %o1] 0x88
129	FUNCTION_END(xf86WriteMmio16LeNB)
130
131	FUNCTION_START(xf86WriteMmio32BeNB, 0)
132	st	%o2, [%o0 + %o1]
133	FUNCTION_END(xf86WriteMmio32BeNB)
134
135	FUNCTION_START(xf86WriteMmio32LeNB, 0)
136	sta	%o2, [%o0 + %o1] 0x88
137	FUNCTION_END(xf86WriteMmio32LeNB)
138
139