1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* General machine architecture & implementation specific
* assembly language routines.
*/
#if defined(lint)
#include <sys/types.h>
#include <sys/machsystm.h>
#include <sys/t_lock.h>
#else /* lint */
#include "assym.h"
#endif /* lint */
#include <sys/asm_linkage.h>
#include <sys/async.h>
#include <sys/machthread.h>
#if defined(lint)
caddr_t
set_trap_table(void)
{
return ((caddr_t)0);
}
#else /* lint */
ENTRY(set_trap_table)
set trap_table, %o1
rdpr %tba, %o0
wrpr %o1, %tba
retl
wrpr %g0, WSTATE_KERN, %wstate
SET_SIZE(set_trap_table)
#endif /* lint */
#if defined(lint)
/*ARGSUSED*/
void
stphys(uint64_t physaddr, int value)
{}
/*ARGSUSED*/
int
ldphys(uint64_t physaddr)
{ return (0); }
/*ARGSUSED*/
void
stdphys(uint64_t physaddr, uint64_t value)
{}
/*ARGSUSED*/
uint64_t
lddphys(uint64_t physaddr)
{ return (0x0ull); }
/* ARGSUSED */
void
stphysio(u_longlong_t physaddr, uint_t value)
{}
/* ARGSUSED */
uint_t
ldphysio(u_longlong_t physaddr)
{ return(0); }
/* ARGSUSED */
void
sthphysio(u_longlong_t physaddr, ushort_t value)
{}
/* ARGSUSED */
ushort_t
ldhphysio(u_longlong_t physaddr)
{ return(0); }
/* ARGSUSED */
void
stbphysio(u_longlong_t physaddr, uchar_t value)
{}
/* ARGSUSED */
uchar_t
ldbphysio(u_longlong_t physaddr)
{ return(0); }
/*ARGSUSED*/
void
stdphysio(u_longlong_t physaddr, u_longlong_t value)
{}
/*ARGSUSED*/
u_longlong_t
lddphysio(u_longlong_t physaddr)
{ return (0ull); }
#else
! Store long word value at physical address
!
! void stdphys(uint64_t physaddr, uint64_t value)
!
ENTRY(stdphys)
/*
* disable interrupts, clear Address Mask to access 64 bit physaddr
*/
rdpr %pstate, %o4
andn %o4, PSTATE_IE | PSTATE_AM, %o5
wrpr %o5, 0, %pstate
stxa %o1, [%o0]ASI_MEM
retl
wrpr %g0, %o4, %pstate ! restore earlier pstate register value
SET_SIZE(stdphys)
! Store long word value at physical i/o address
!
! void stdphysio(u_longlong_t physaddr, u_longlong_t value)
!
ENTRY(stdphysio)
/*
* disable interrupts, clear Address Mask to access 64 bit physaddr
*/
rdpr %pstate, %o4
andn %o4, PSTATE_IE | PSTATE_AM, %o5
wrpr %o5, 0, %pstate ! clear IE, AM bits
stxa %o1, [%o0]ASI_IO
retl
wrpr %g0, %o4, %pstate ! restore earlier pstate register value
SET_SIZE(stdphysio)
!
! Load long word value at physical address
!
! uint64_t lddphys(uint64_t physaddr)
!
ENTRY(lddphys)
rdpr %pstate, %o4
andn %o4, PSTATE_IE | PSTATE_AM, %o5
wrpr %o5, 0, %pstate
ldxa [%o0]ASI_MEM, %o0
retl
wrpr %g0, %o4, %pstate ! restore earlier pstate register value
SET_SIZE(lddphys)
!
! Load long word value at physical i/o address
!
! unsigned long long lddphysio(u_longlong_t physaddr)
!
ENTRY(lddphysio)
rdpr %pstate, %o4
andn %o4, PSTATE_IE | PSTATE_AM, %o5
wrpr %o5, 0, %pstate ! clear IE, AM bits
ldxa [%o0]ASI_IO, %o0
retl
wrpr %g0, %o4, %pstate ! restore earlier pstate register value
SET_SIZE(lddphysio)
!
! Store value at physical address
!
! void stphys(uint64_t physaddr, int value)
!
ENTRY(stphys)
rdpr %pstate, %o4
andn %o4, PSTATE_IE | PSTATE_AM, %o5
wrpr %o5, 0, %pstate
sta %o1, [%o0]ASI_MEM
retl
wrpr %g0, %o4, %pstate ! restore earlier pstate register value
SET_SIZE(stphys)
!
! load value at physical address
!
! int ldphys(uint64_t physaddr)
!
ENTRY(ldphys)
rdpr %pstate, %o4
andn %o4, PSTATE_IE | PSTATE_AM, %o5
wrpr %o5, 0, %pstate
lda [%o0]ASI_MEM, %o0
srl %o0, 0, %o0 ! clear upper 32 bits
retl
wrpr %g0, %o4, %pstate ! restore earlier pstate register value
SET_SIZE(ldphys)
!
! Store value into physical address in I/O space
!
! void stphysio(u_longlong_t physaddr, uint_t value)
!
ENTRY_NP(stphysio)
rdpr %pstate, %o4 /* read PSTATE reg */
andn %o4, PSTATE_IE | PSTATE_AM, %o5
wrpr %o5, 0, %pstate
stwa %o1, [%o0]ASI_IO /* store value via bypass ASI */
retl
wrpr %g0, %o4, %pstate /* restore the PSTATE */
SET_SIZE(stphysio)
!
! Store value into physical address in I/O space
!
! void sthphysio(u_longlong_t physaddr, ushort_t value)
!
ENTRY_NP(sthphysio)
rdpr %pstate, %o4 /* read PSTATE reg */
andn %o4, PSTATE_IE | PSTATE_AM, %o5
wrpr %o5, 0, %pstate
stha %o1, [%o0]ASI_IO /* store value via bypass ASI */
retl
wrpr %g0, %o4, %pstate /* restore the PSTATE */
SET_SIZE(sthphysio)
!
! Store value into one byte physical address in I/O space
!
! void stbphysio(u_longlong_t physaddr, uchar_t value)
!
ENTRY_NP(stbphysio)
rdpr %pstate, %o4 /* read PSTATE reg */
andn %o4, PSTATE_IE | PSTATE_AM, %o5
wrpr %o5, 0, %pstate
stba %o1, [%o0]ASI_IO /* store byte via bypass ASI */
retl
wrpr %g0, %o4, %pstate /* restore the PSTATE */
SET_SIZE(stbphysio)
!
! load value at physical address in I/O space
!
! uint_t ldphysio(u_longlong_t physaddr)
!
ENTRY_NP(ldphysio)
rdpr %pstate, %o4 /* read PSTATE reg */
andn %o4, PSTATE_IE | PSTATE_AM, %o5
wrpr %o5, 0, %pstate
lduwa [%o0]ASI_IO, %o0 /* load value via bypass ASI */
retl
wrpr %g0, %o4, %pstate /* restore pstate */
SET_SIZE(ldphysio)
!
! load value at physical address in I/O space
!
! ushort_t ldhphysio(u_longlong_t physaddr)
!
ENTRY_NP(ldhphysio)
rdpr %pstate, %o4 /* read PSTATE reg */
andn %o4, PSTATE_IE | PSTATE_AM, %o5
wrpr %o5, 0, %pstate
lduha [%o0]ASI_IO, %o0 /* load value via bypass ASI */
retl
wrpr %g0, %o4, %pstate /* restore pstate */
SET_SIZE(ldhphysio)
!
! load byte value at physical address in I/O space
!
! uchar_t ldbphysio(u_longlong_t physaddr)
!
ENTRY_NP(ldbphysio)
rdpr %pstate, %o4 /* read PSTATE reg */
andn %o4, PSTATE_IE | PSTATE_AM, %o5
wrpr %o5, 0, %pstate
lduba [%o0]ASI_IO, %o0 /* load value via bypass ASI */
retl
wrpr %g0, %o4, %pstate /* restore pstate */
SET_SIZE(ldbphysio)
#endif /* lint */
/*
* save_gsr(kfpu_t *fp)
* Store the graphics status register
*/
#if defined(lint) || defined(__lint)
/* ARGSUSED */
void
save_gsr(kfpu_t *fp)
{}
#else /* lint */
ENTRY_NP(save_gsr)
rd %gsr, %g2 ! save gsr
retl
stx %g2, [%o0 + FPU_GSR]
SET_SIZE(save_gsr)
#endif /* lint */
#if defined(lint) || defined(__lint)
/* ARGSUSED */
void
restore_gsr(kfpu_t *fp)
{}
#else /* lint */
ENTRY_NP(restore_gsr)
ldx [%o0 + FPU_GSR], %g2
wr %g2, %g0, %gsr
retl
nop
SET_SIZE(restore_gsr)
#endif /* lint */
/*
* uint64_t
* _fp_read_pgsr()
* Get the graphics status register info from fp and return it
*/
#if defined(lint) || defined(__lint)
/* ARGSUSED */
uint64_t
_fp_read_pgsr(kfpu_t *fp)
{ return 0; }
#else /* lint */
ENTRY_NP(_fp_read_pgsr)
retl
rd %gsr, %o0
SET_SIZE(_fp_read_pgsr)
#endif /* lint */
/*
* uint64_t
* get_gsr(kfpu_t *fp)
* Get the graphics status register info from fp and return it
*/
#if defined(lint) || defined(__lint)
/* ARGSUSED */
uint64_t
get_gsr(kfpu_t *fp)
{ return 0; }
#else /* lint */
ENTRY_NP(get_gsr)
retl
ldx [%o0 + FPU_GSR], %o0
SET_SIZE(get_gsr)
#endif
/*
* _fp_write_pgsr(uint64_t *buf, kfpu_t *fp)
* Set the graphics status register info to fp from buf
*/
#if defined(lint) || defined(__lint)
/* ARGSUSED */
void
_fp_write_pgsr(uint64_t buf, kfpu_t *fp)
{}
#else /* lint */
ENTRY_NP(_fp_write_pgsr)
retl
mov %o0, %gsr
SET_SIZE(_fp_write_pgsr)
#endif /* lint */
/*
* set_gsr(uint64_t buf, kfpu_t *fp)
* Set the graphics status register info to fp from buf
*/
#if defined(lint) || defined(__lint)
/* ARGSUSED */
void
set_gsr(uint64_t buf, kfpu_t *fp)
{}
#else /* lint */
ENTRY_NP(set_gsr)
retl
stx %o0, [%o1 + FPU_GSR]
SET_SIZE(set_gsr)
#endif /* lint */
#if defined(lint) || defined(__lint)
void
kdi_cpu_index(void)
{
}
#else /* lint */
ENTRY_NP(kdi_cpu_index)
CPU_INDEX(%g1, %g2)
jmp %g7
nop
SET_SIZE(kdi_cpu_index)
#endif /* lint */
|