4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
26 * General machine architecture & implementation specific
27 * assembly language routines.
30 #include <sys/types.h>
31 #include <sys/t_lock.h>
36 #define CPU_MODULE /* need it for NSEC_SHIFT used by NATIVE_TIME_TO_NSEC() */
38 #include <sys/asm_linkage.h>
39 #include <sys/machsystm.h>
40 #include <sys/machthread.h>
41 #include <sys/machclock.h>
42 #include <sys/privregs.h>
43 #include <sys/cmpregs.h>
44 #include <sys/clock.h>
45 #include <sys/fpras.h>
46 #include <sys/soft_state.h>
57 * This isn't the routine you're looking for.
59 * The routine simply returns the value of %tick on the *current* processor.
60 * Most of the time, gettick() [which in turn maps to %stick on platforms
61 * that have different CPU %tick rates] is what you want.
65 RD_TICK
(%o0
,%o1
,%o2
,__LINE__
)
68 SET_SIZE
(ultra_gettick
)
75 set_mmfsa_scratchpad
(caddr_t vaddr
)
80 ENTRY
(set_mmfsa_scratchpad
)
81 stxa
%o0
, [%g0
]ASI_SCRATCHPAD
84 SET_SIZE
(set_mmfsa_scratchpad
)
89 get_mmfsa_scratchpad
()
94 ENTRY
(get_mmfsa_scratchpad
)
95 ldxa
[%g0
]ASI_SCRATCHPAD
, %o0
98 SET_SIZE
(get_mmfsa_scratchpad
)
106 cpu_intrq_unregister_powerdown
(uint64_t doneflag_va
)
112 * Called from a x-trap at tl1 must use %g1 as arg
113 * and save/restore %o0-%o5 after hypervisor calls
116 ENTRY
(cpu_intrq_unregister_powerdown
)
119 add %g2
, CPU_MCPU
, %g2
128 ldx [%g2
+ MCPU_CPU_Q_BASE
], %o1
133 ldx [%g2
+ MCPU_DEV_Q_BASE
], %o1
138 ldx [%g2
+ MCPU_RQ_BASE
], %o1
143 ldx [%g2
+ MCPU_NRQ_BASE
], %o1
162 * This CPU is on its way out. Spin here
163 * until the DR unconfigure code stops it.
164 * Returning would put it back in the OS
165 * where it might grab resources like locks,
166 * causing some nastiness to occur.
171 SET_SIZE
(cpu_intrq_unregister_powerdown
)
184 * Get the processor ID.
185 * === MID reg as specified in 15dec89 sun4u spec, sec 5.4.3
188 ENTRY
(getprocessorid
)
192 SET_SIZE
(getprocessorid
)
196 #if defined(lint) || defined(__lint)
200 tick2ns
(hrtime_t tick
, uint_t cpuid
)
207 ! Use nsec_scale for sun4v which is based on
%stick
209 NATIVE_TIME_TO_NSEC
(%o0
, %o2
, %o3
)
220 set_cmp_error_steering
(void
)
225 ENTRY
(set_cmp_error_steering
)
228 SET_SIZE
(set_cmp_error_steering
)
245 mov
-1, %o0
! XXXQ no version available
246 SET_SIZE
(ultra_getver
)
253 fpras_chkfn_type1
(void
)
259 * Check instructions using just the AX pipelines, designed by
262 * This function must match a struct fpras_chkfn and must be
263 * block aligned. A zero return means all was well. These
264 * instructions are chosen to be sensitive to bit corruptions
265 * on the fpras rewrite, so if a bit corruption still produces
266 * a valid instruction we should still get an incorrect result
267 * here. This function is never called directly - it is copied
268 * into per-cpu and per-operation buffers; it must therefore
269 * be absolutely position independent. If an illegal instruction
270 * is encountered then the trap handler trampolines to the final
271 * three instructions of this function.
273 * We want two instructions that are complements of one another,
274 * and which can perform a calculation with a known result.
278 * | 0 0 | rd | 1 0 0 | imm22 |
279 * 31 30 29 25 24 22 21 0
281 * ADDCCC with two source registers:
283 * | 1 0 | rd | 0 1 1 0 0 0 | rs1 | 0 | - | rs2 |
284 * 31 30 29 25 24 19 18 14 13 12 5 4 0
286 * We can choose rd and imm2 of the SETHI and rd, rs1 and rs2 of
287 * the ADDCCC to obtain instructions that are complements in all but
290 * Registers are numbered as follows:
325 * For register r[n], register r[31-n] is the complement. We must
326 * avoid use of %i6/%i7 and %o6/%o7 as well as %g7. Clearly we need
327 * to use a local or input register as one half of the pair, which
328 * requires us to obtain our own register window or take steps
329 * to preserve any local or input we choose to use. We choose
330 * %o1 as rd for the SETHI, so rd of the ADDCCC must be %l6.
331 * We'll use %o1 as rs1 and %l6 as rs2 of the ADDCCC, which then
332 * requires that imm22 be 0b111 10110 1 11111111 01001 or 0x3dbfe9,
333 * or %hi(0xf6ffa400). This determines the value of the constant
336 * The constant CBV1 is chosen such that an initial subcc %g0, CBV1
337 * will set the carry bit and every addccc thereafter will continue
338 * to generate a carry. Other values are possible for CBV1 - this
339 * is just one that works this way.
341 * Finally CBV3 is the expected answer when we perform our repeated
342 * calculations on CBV1 and CBV2 - it is not otherwise specially
343 * derived. If this result is not obtained then a corruption has
344 * occured during the FPRAS_REWRITE of one of the two blocks of
345 * 16 instructions. A corruption could also result in an illegal
346 * instruction or other unexpected trap - we catch illegal
347 * instruction traps in the PC range and trampoline to the
348 * last instructions of the function to return a failure indication.
353 #define CBV2 0xf6ffa400
354 #define CBV3 0x66f9d800
358 #define SETHI_CBV2_CBR1 sethi %hi(CBV2), CBR1
359 #define ADDCCC_CBR1_CBR2_CBR2 addccc CBR1, CBR2, CBR2
362 ENTRY_NP
(fpras_chkfn_type1
)
363 mov CBR2
, CBO2
! 1, preserve CBR2 of
(callers
) window
364 mov FPRAS_OK
, %o0
! 2, default return value
366 subcc
%g0
, CBV1
, CBR2
! 4
369 1: SETHI_CBV2_CBR1
! 1
370 ADDCCC_CBR1_CBR2_CBR2
! 2
372 ADDCCC_CBR1_CBR2_CBR2
! 4
374 ADDCCC_CBR1_CBR2_CBR2
! 6
376 ADDCCC_CBR1_CBR2_CBR2
! 8
378 ADDCCC_CBR1_CBR2_CBR2
! 10
380 ADDCCC_CBR1_CBR2_CBR2
! 12
382 ADDCCC_CBR1_CBR2_CBR2
! 14
384 ADDCCC_CBR1_CBR2_CBR2
! 16
386 ADDCCC_CBR1_CBR2_CBR2
! 1
388 ADDCCC_CBR1_CBR2_CBR2
! 3
390 ADDCCC_CBR1_CBR2_CBR2
! 5
392 ADDCCC_CBR1_CBR2_CBR2
! 7
394 ADDCCC_CBR1_CBR2_CBR2
! 9
396 ADDCCC_CBR1_CBR2_CBR2
! 11
398 ADDCCC_CBR1_CBR2_CBR2
! 13
400 ADDCCC_CBR1_CBR2_CBR2
! 15
403 addc CBR1
, CBR2
, CBR2
! 1
404 sethi
%hi
(CBV3
), CBR1
! 2
406 movnz
%icc
, FPRAS_BADCALC
, %o0
! 4, how detected
408 mov CBO2
, CBR2
! 6, restore borrowed register
409 .skip 4*(13-7+1) ! 7 - 13
411 ! illegal instr
'n trap comes here
413 mov CBO2, CBR2 ! 14, restore borrowed register
415 mov FPRAS_BADTRAP, %o0 ! 16, how detected
416 SET_SIZE(fpras_chkfn_type1)
420 char soft_state_message_strings[SOLARIS_SOFT_STATE_MSG_CNT][SSM_SIZE];
423 .global soft_state_message_strings
426 soft_state_message_strings:
427 .asciz SOLARIS_SOFT_STATE_BOOT_MSG_STR
429 .asciz SOLARIS_SOFT_STATE_RUN_MSG_STR
431 .asciz SOLARIS_SOFT_STATE_HALT_MSG_STR
433 .asciz SOLARIS_SOFT_STATE_POWER_MSG_STR
435 .asciz SOLARIS_SOFT_STATE_PANIC_MSG_STR
437 .asciz SOLARIS_SOFT_STATE_REBOOT_MSG_STR
439 .asciz SOLARIS_SOFT_STATE_DEBUG_MSG_STR
441 .skip SSM_SIZE /* saved message */