Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: hpv_console.s | |
5 | * Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
6 | * 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
7 | * | |
8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; version 2 of the License. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 | * | |
23 | * For the avoidance of doubt, and except that if any non-GPL license | |
24 | * choice is available it will apply instead, Sun elects to use only | |
25 | * the General Public License version 2 (GPLv2) at this time for any | |
26 | * software where a choice of GPL license versions is made | |
27 | * available with the language indicating that GPLv2 or any later version | |
28 | * may be used, or where a choice of which version of the GPL is applied is | |
29 | * otherwise unspecified. | |
30 | * | |
31 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
32 | * CA 95054 USA or visit www.sun.com if you need additional information or | |
33 | * have any questions. | |
34 | * | |
35 | * | |
36 | * ========== Copyright Header End ============================================ | |
37 | */ | |
38 | #ident "@(#) hpv_console.s 1.2 04/10/12 12:12:01" | |
39 | #include <sys/asm_linkage.h> | |
40 | ||
41 | /* | |
42 | * Hypervisor calls | |
43 | */ | |
44 | ||
45 | #include <sys/asm_linkage.h> | |
46 | #include "mon_macros.h" | |
47 | ||
48 | #define EWOULDBLOCK 9 | |
49 | ||
50 | .data | |
51 | .align 8 | |
52 | .global hv_getch_mutex | |
53 | .type hv_getch_mutex, #object | |
54 | .size hv_getch_mutex, 8 | |
55 | hv_getch_mutex: | |
56 | .xword 0 | |
57 | ||
58 | .global hv_putch_mutex | |
59 | .type hv_putch_mutex, #object | |
60 | .size hv_putch_mutex, 8 | |
61 | hv_putch_mutex: | |
62 | .xword 0 | |
63 | ||
64 | ||
65 | #if defined(lint) || defined(__lint) | |
66 | ||
67 | /*ARGSUSED*/ | |
68 | int hv_writechars( char * buf, int len ) | |
69 | { | |
70 | return 0; | |
71 | } | |
72 | ||
73 | #else | |
74 | /* | |
75 | * This will need a mutex to prevent the output from | |
76 | * differing cpus coliding and interleaving. | |
77 | * | |
78 | * There is still a printf mutex that should protect | |
79 | * nearly all of the time. So that means the penalty | |
80 | * for acquiring a mutex here should be miniscule. | |
81 | */ | |
82 | ENTRY2( hv_writechars, writechars ) | |
83 | /* | |
84 | * %i0 buffer pointer | |
85 | * %i1 count | |
86 | * | |
87 | */ | |
88 | save %sp, -SA(MINFRAME), %sp | |
89 | ||
90 | brz %i1, 3f | |
91 | mov %g0, %l0 | |
92 | ||
93 | subcc %i1, 1, %l1 | |
94 | bneg %xcc, 4f | |
95 | nop | |
96 | ||
97 | GET_MUTEX( hv_putch_mutex, %l6, %l7 ) | |
98 | ||
99 | 1: | |
100 | call hv_cnputchar | |
101 | ldub [%i0 + %l0], %o0 | |
102 | cmp %l0, %l1 | |
103 | blt %xcc, 1b | |
104 | add %l0, 1, %l0 | |
105 | ||
106 | 2: | |
107 | FREE_MUTEX( hv_putch_mutex, %l6, %l7 ) | |
108 | 3: | |
109 | mov %l0, %i0 | |
110 | ret | |
111 | restore | |
112 | SET_SIZE( hv_writechars ) | |
113 | 4: | |
114 | mov %l0, %i0 ! return count of how many read | |
115 | ret | |
116 | restore | |
117 | ||
118 | #endif | |
119 | ||
120 | #if defined(lint) || defined(__lint) | |
121 | ||
122 | /*ARGSUSED*/ | |
123 | int hv_readchars( char * buf, int len ) | |
124 | { | |
125 | return 0; | |
126 | } | |
127 | ||
128 | #else | |
129 | /* | |
130 | * This will need a mutex to prevent the output from | |
131 | * differing cpus coliding and interleaving. | |
132 | * | |
133 | * There is still a printf mutex that should protect | |
134 | * nearly all of the time. So that means the penalty | |
135 | * for acquiring a mutex here should be miniscule. | |
136 | */ | |
137 | .data | |
138 | ||
139 | .global console_master | |
140 | .type console_master, #object | |
141 | ||
142 | .align 8 | |
143 | .global hv_read_result | |
144 | .type hv_read_result, #object | |
145 | hv_read_result: | |
146 | .xword 0 | |
147 | #if 0 | |
148 | ENTRY2( hv_readchars, readchars ) | |
149 | /* | |
150 | * %i0 buffer pointer | |
151 | * %i1 count | |
152 | * | |
153 | * returns count of characters read | |
154 | */ | |
155 | save %sp, -SA(MINFRAME), %sp | |
156 | brz %i1, 4f | |
157 | mov %g0, %l0 | |
158 | ||
159 | subcc %i1, 1, %l1 | |
160 | bneg %xcc, 4f | |
161 | nop | |
162 | ||
163 | /* | |
164 | * See if we are running on the console master - if not do not | |
165 | * issue the console read | |
166 | */ | |
167 | ||
168 | call getlogicalcpuid | |
169 | nop | |
170 | ||
171 | setx console_master, %l5, %l6 | |
172 | ld [%l6], %l5 | |
173 | cmp %o0, %l5 | |
174 | bne %icc, 4f ! j.if not console master | |
175 | nop | |
176 | ||
177 | ||
178 | GET_MUTEX( hv_getch_mutex, %l6, %l7 ) | |
179 | ||
180 | /* while less than buffer and result is 0 */ | |
181 | ||
182 | 1: | |
183 | call hv_cngetchar | |
184 | add %i0, %l0, %o0 | |
185 | ||
186 | cmp %o0, EWOULDBLOCK | |
187 | be 2f | |
188 | nop | |
189 | ||
190 | brnz %o0, 3f ! non zero return | |
191 | nop | |
192 | cmp %l0, %l1 | |
193 | blt %xcc, 1b | |
194 | add %l0, 1, %l0 | |
195 | 2: | |
196 | FREE_MUTEX( hv_getch_mutex, %l6, %l7 ) | |
197 | ||
198 | 4: | |
199 | mov %l0, %i0 ! return count of how many read | |
200 | ret | |
201 | restore | |
202 | ||
203 | 3: | |
204 | setx hv_read_result, %l3, %l2 | |
205 | ba 2b | |
206 | stx %o0,[%l2] | |
207 | #endif | |
208 | ||
209 | SET_SIZE( hv_readchars ) | |
210 | ||
211 | ||
212 | #endif | |
213 |