17c478bd9Sstevel@tonic-gate/* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57bafd143Sjb * Common Development and Distribution License (the "License"). 67bafd143Sjb * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate/* 22b52a336eSPavel Tatashin * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate#include "assym.h" 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate/* 287c478bd9Sstevel@tonic-gate * General assembly language routines. 297c478bd9Sstevel@tonic-gate * It is the intent of this file to contain routines that are 307c478bd9Sstevel@tonic-gate * specific to cpu architecture. 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate/* 347c478bd9Sstevel@tonic-gate * WARNING: If you add a fast trap handler which can be invoked by a 357c478bd9Sstevel@tonic-gate * non-privileged user, you may have to use the FAST_TRAP_DONE macro 367c478bd9Sstevel@tonic-gate * instead of "done" instruction to return back to the user mode. See 377c478bd9Sstevel@tonic-gate * comments for the "fast_trap_done" entry point for more information. 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gate#define FAST_TRAP_DONE \ 407c478bd9Sstevel@tonic-gate ba,a fast_trap_done 417c478bd9Sstevel@tonic-gate 42023e71deSHaik Aftandilian#include <sys/machclock.h> 437c478bd9Sstevel@tonic-gate#include <sys/clock.h> 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h> 477c478bd9Sstevel@tonic-gate#include <sys/privregs.h> 481e2e7a75Shuah#include <vm/hat_sfmmu.h> 497c478bd9Sstevel@tonic-gate#include <sys/machparam.h> /* To get SYSBASE and PAGESIZE */ 507c478bd9Sstevel@tonic-gate#include <sys/machthread.h> 517c478bd9Sstevel@tonic-gate#include <sys/clock.h> 527c478bd9Sstevel@tonic-gate#include <sys/intreg.h> 537c478bd9Sstevel@tonic-gate#include <sys/psr_compat.h> 547c478bd9Sstevel@tonic-gate#include <sys/isa_defs.h> 557c478bd9Sstevel@tonic-gate#include <sys/dditypes.h> 567c478bd9Sstevel@tonic-gate#include <sys/intr.h> 577c478bd9Sstevel@tonic-gate#include <sys/hypervisor_api.h> 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate#include "assym.h" 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate#define ICACHE_FLUSHSZ 0x20 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate/* 649b0bb795SJohn Levon * Softint generated when counter field of tick reg matches value field 657c478bd9Sstevel@tonic-gate * of tick_cmpr reg 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate ENTRY_NP(tickcmpr_set) 687c478bd9Sstevel@tonic-gate ! get 64-bit clock_cycles interval 697c478bd9Sstevel@tonic-gate mov %o0, %o2 707c478bd9Sstevel@tonic-gate mov 8, %o3 ! A reasonable initial step size 717c478bd9Sstevel@tonic-gate1: 727c478bd9Sstevel@tonic-gate WR_TICKCMPR(%o2,%o4,%o5,__LINE__) ! Write to TICK_CMPR 737c478bd9Sstevel@tonic-gate 74023e71deSHaik Aftandilian GET_NATIVE_TIME(%o0,%o4,%o5,__LINE__) ! Read %tick to confirm the 75023e71deSHaik Aftandilian ! value we wrote was in the 76023e71deSHaik Aftandilian ! future. 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate cmp %o2, %o0 ! If the value we wrote was in the 797c478bd9Sstevel@tonic-gate bg,pt %xcc, 2f ! future, then blow out of here. 801e2e7a75Shuah sllx %o3, 1, %o3 ! If not, then double our step size, 817c478bd9Sstevel@tonic-gate ba,pt %xcc, 1b ! and take another lap. 821e2e7a75Shuah add %o0, %o3, %o2 ! 837c478bd9Sstevel@tonic-gate2: 847c478bd9Sstevel@tonic-gate retl 851e2e7a75Shuah nop 867c478bd9Sstevel@tonic-gate SET_SIZE(tickcmpr_set) 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate ENTRY_NP(tickcmpr_disable) 897c478bd9Sstevel@tonic-gate mov 1, %g1 907c478bd9Sstevel@tonic-gate sllx %g1, TICKINT_DIS_SHFT, %o0 917c478bd9Sstevel@tonic-gate WR_TICKCMPR(%o0,%o4,%o5,__LINE__) ! Write to TICK_CMPR 927c478bd9Sstevel@tonic-gate retl 931e2e7a75Shuah nop 947c478bd9Sstevel@tonic-gate SET_SIZE(tickcmpr_disable) 957c478bd9Sstevel@tonic-gate 969b0bb795SJohn Levon .seg ".text" 979b0bb795SJohn Levontick_write_delta_panic: 989b0bb795SJohn Levon .asciz "tick_write_delta: not supported, delta: 0x%lx" 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate/* 10100a57bdfSHaik Aftandilian * tick_write_delta() is intended to increment %stick by the specified delta, 10200a57bdfSHaik Aftandilian * but %stick is only writeable in hyperprivileged mode and at present there 10300a57bdfSHaik Aftandilian * is no provision for this. tick_write_delta is called by the cylic subsystem 10400a57bdfSHaik Aftandilian * if a negative %stick delta is observed after cyclic processing is resumed 10500a57bdfSHaik Aftandilian * after an event such as an OS suspend/resume. On sun4v, the suspend/resume 10600a57bdfSHaik Aftandilian * routines should adjust the %stick offset preventing the cyclic subsystem 10700a57bdfSHaik Aftandilian * from detecting a negative delta. If a negative delta is detected, panic the 10800a57bdfSHaik Aftandilian * system. The negative delta could be caused by improper %stick 10900a57bdfSHaik Aftandilian * synchronization after a suspend/resume. 1107c478bd9Sstevel@tonic-gate */ 1117c478bd9Sstevel@tonic-gate ENTRY_NP(tick_write_delta) 1127c478bd9Sstevel@tonic-gate sethi %hi(tick_write_delta_panic), %o1 1137c478bd9Sstevel@tonic-gate save %sp, -SA(MINFRAME), %sp ! get a new window to preserve caller 11400a57bdfSHaik Aftandilian mov %i0, %o1 1157c478bd9Sstevel@tonic-gate call panic 1161e2e7a75Shuah or %i1, %lo(tick_write_delta_panic), %o0 1177c478bd9Sstevel@tonic-gate /*NOTREACHED*/ 1187c478bd9Sstevel@tonic-gate retl 1191e2e7a75Shuah nop 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate ENTRY_NP(tickcmpr_disabled) 122023e71deSHaik Aftandilian RD_TICKCMPR(%g1,%o0,%o1,__LINE__) 1237c478bd9Sstevel@tonic-gate retl 1241e2e7a75Shuah srlx %g1, TICKINT_DIS_SHFT, %o0 1257c478bd9Sstevel@tonic-gate SET_SIZE(tickcmpr_disabled) 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate/* 1287c478bd9Sstevel@tonic-gate * Get current tick 1297c478bd9Sstevel@tonic-gate */ 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate ENTRY(gettick) 132b52a336eSPavel Tatashin ALTENTRY(randtick) 133023e71deSHaik Aftandilian GET_NATIVE_TIME(%o0,%o2,%o3,__LINE__) 1347c478bd9Sstevel@tonic-gate retl 1351e2e7a75Shuah nop 136b52a336eSPavel Tatashin SET_SIZE(randtick) 1377c478bd9Sstevel@tonic-gate SET_SIZE(gettick) 1387c478bd9Sstevel@tonic-gate 139023e71deSHaik Aftandilian/* 140023e71deSHaik Aftandilian * Get current tick. For trapstat use only. 141023e71deSHaik Aftandilian */ 142023e71deSHaik Aftandilian ENTRY(rdtick) 143023e71deSHaik Aftandilian retl 144023e71deSHaik Aftandilian RD_TICK_PHYSICAL(%o0) 145023e71deSHaik Aftandilian SET_SIZE(rdtick) 146023e71deSHaik Aftandilian 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate/* 1497c478bd9Sstevel@tonic-gate * Return the counter portion of the tick register. 1507c478bd9Sstevel@tonic-gate */ 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate ENTRY_NP(gettick_counter) 153023e71deSHaik Aftandilian RD_TICK(%o0,%o1,%o2,__LINE__) 1547c478bd9Sstevel@tonic-gate retl 155023e71deSHaik Aftandilian nop 1567c478bd9Sstevel@tonic-gate SET_SIZE(gettick_counter) 157023e71deSHaik Aftandilian 158023e71deSHaik Aftandilian ENTRY_NP(gettick_npt) 159023e71deSHaik Aftandilian RD_TICK_PHYSICAL(%o0) 160023e71deSHaik Aftandilian retl 161023e71deSHaik Aftandilian srlx %o0, 63, %o0 162023e71deSHaik Aftandilian SET_SIZE(gettick_npt) 163023e71deSHaik Aftandilian 164023e71deSHaik Aftandilian ENTRY_NP(getstick_npt) 165023e71deSHaik Aftandilian RD_STICK_PHYSICAL(%o0) 166023e71deSHaik Aftandilian retl 167023e71deSHaik Aftandilian srlx %o0, 63, %o0 168023e71deSHaik Aftandilian SET_SIZE(getstick_npt) 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate/* 1717c478bd9Sstevel@tonic-gate * Provide a C callable interface to the trap that reads the hi-res timer. 1727c478bd9Sstevel@tonic-gate * Returns 64-bit nanosecond timestamp in %o0 and %o1. 1737c478bd9Sstevel@tonic-gate */ 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate ENTRY_NP(gethrtime) 176023e71deSHaik Aftandilian GET_HRTIME(%g1,%o0,%o1,%o2,%o3,%o4,%o5,%g2,__LINE__) 1777c478bd9Sstevel@tonic-gate ! %g1 = hrtime 1787c478bd9Sstevel@tonic-gate retl 1791e2e7a75Shuah mov %g1, %o0 1807c478bd9Sstevel@tonic-gate SET_SIZE(gethrtime) 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate ENTRY_NP(gethrtime_unscaled) 183023e71deSHaik Aftandilian GET_NATIVE_TIME(%g1,%o2,%o3,__LINE__) ! %g1 = native time 1847c478bd9Sstevel@tonic-gate retl 1851e2e7a75Shuah mov %g1, %o0 1867c478bd9Sstevel@tonic-gate SET_SIZE(gethrtime_unscaled) 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate ENTRY_NP(gethrtime_waitfree) 1897c478bd9Sstevel@tonic-gate ALTENTRY(dtrace_gethrtime) 190023e71deSHaik Aftandilian GET_NATIVE_TIME(%g1,%o2,%o3,__LINE__) ! %g1 = native time 1917c478bd9Sstevel@tonic-gate NATIVE_TIME_TO_NSEC(%g1, %o2, %o3) 1927c478bd9Sstevel@tonic-gate retl 1931e2e7a75Shuah mov %g1, %o0 1947c478bd9Sstevel@tonic-gate SET_SIZE(dtrace_gethrtime) 1957c478bd9Sstevel@tonic-gate SET_SIZE(gethrtime_waitfree) 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate ENTRY(gethrtime_max) 1987c478bd9Sstevel@tonic-gate NATIVE_TIME_MAX(%g1) 1997c478bd9Sstevel@tonic-gate NATIVE_TIME_TO_NSEC(%g1, %o0, %o1) 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate ! hrtime_t's are signed, max hrtime_t must be positive 2027c478bd9Sstevel@tonic-gate mov -1, %o2 2037c478bd9Sstevel@tonic-gate brlz,a %g1, 1f 2041e2e7a75Shuah srlx %o2, 1, %g1 2057c478bd9Sstevel@tonic-gate1: 2067c478bd9Sstevel@tonic-gate retl 2071e2e7a75Shuah mov %g1, %o0 2087c478bd9Sstevel@tonic-gate SET_SIZE(gethrtime_max) 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate ENTRY(scalehrtime) 2117c478bd9Sstevel@tonic-gate ldx [%o0], %o1 2127c478bd9Sstevel@tonic-gate NATIVE_TIME_TO_NSEC(%o1, %o2, %o3) 2137c478bd9Sstevel@tonic-gate retl 2141e2e7a75Shuah stx %o1, [%o0] 2157c478bd9Sstevel@tonic-gate SET_SIZE(scalehrtime) 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate/* 2187c478bd9Sstevel@tonic-gate * Fast trap to return a timestamp, uses trap window, leaves traps 2197c478bd9Sstevel@tonic-gate * disabled. Returns a 64-bit nanosecond timestamp in %o0 and %o1. 2207c478bd9Sstevel@tonic-gate * 2217c478bd9Sstevel@tonic-gate * This is the handler for the ST_GETHRTIME trap. 2227c478bd9Sstevel@tonic-gate */ 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate ENTRY_NP(get_timestamp) 225023e71deSHaik Aftandilian GET_HRTIME(%g1,%g2,%g3,%g4,%g5,%o0,%o1,%o2,__LINE__) 226023e71deSHaik Aftandilian ! %g1 = hrtime 2277c478bd9Sstevel@tonic-gate srlx %g1, 32, %o0 ! %o0 = hi32(%g1) 2287c478bd9Sstevel@tonic-gate srl %g1, 0, %o1 ! %o1 = lo32(%g1) 2297c478bd9Sstevel@tonic-gate FAST_TRAP_DONE 2307c478bd9Sstevel@tonic-gate SET_SIZE(get_timestamp) 2317c478bd9Sstevel@tonic-gate 2327c478bd9Sstevel@tonic-gate/* 2337c478bd9Sstevel@tonic-gate * Macro to convert GET_HRESTIME() bits into a timestamp. 2347c478bd9Sstevel@tonic-gate * 2357c478bd9Sstevel@tonic-gate * We use two separate macros so that the platform-dependent GET_HRESTIME() 2367c478bd9Sstevel@tonic-gate * can be as small as possible; CONV_HRESTIME() implements the generic part. 2377c478bd9Sstevel@tonic-gate */ 2387c478bd9Sstevel@tonic-gate#define CONV_HRESTIME(hrestsec, hrestnsec, adj, nslt, nano) \ 2397c478bd9Sstevel@tonic-gate brz,pt adj, 3f; /* no adjustments, it's easy */ \ 2407c478bd9Sstevel@tonic-gate add hrestnsec, nslt, hrestnsec; /* hrest.tv_nsec += nslt */ \ 2417c478bd9Sstevel@tonic-gate brlz,pn adj, 2f; /* if hrestime_adj negative */ \ 242646e55b6Scth srlx nslt, ADJ_SHIFT, nslt; /* delay: nslt >>= 4 */ \ 2437c478bd9Sstevel@tonic-gate subcc adj, nslt, %g0; /* hrestime_adj - nslt/16 */ \ 2447c478bd9Sstevel@tonic-gate movg %xcc, nslt, adj; /* adj by min(adj, nslt/16) */ \ 2457c478bd9Sstevel@tonic-gate ba 3f; /* go convert to sec/nsec */ \ 2461e2e7a75Shuah add hrestnsec, adj, hrestnsec; /* delay: apply adjustment */ \ 2477c478bd9Sstevel@tonic-gate2: addcc adj, nslt, %g0; /* hrestime_adj + nslt/16 */ \ 2487c478bd9Sstevel@tonic-gate bge,a,pt %xcc, 3f; /* is adj less negative? */ \ 2491e2e7a75Shuah add hrestnsec, adj, hrestnsec; /* yes: hrest.nsec += adj */ \ 2507c478bd9Sstevel@tonic-gate sub hrestnsec, nslt, hrestnsec; /* no: hrest.nsec -= nslt/16 */ \ 2517c478bd9Sstevel@tonic-gate3: cmp hrestnsec, nano; /* more than a billion? */ \ 2527c478bd9Sstevel@tonic-gate bl,pt %xcc, 4f; /* if not, we're done */ \ 2531e2e7a75Shuah nop; /* delay: do nothing :( */ \ 2547c478bd9Sstevel@tonic-gate add hrestsec, 1, hrestsec; /* hrest.tv_sec++; */ \ 2557c478bd9Sstevel@tonic-gate sub hrestnsec, nano, hrestnsec; /* hrest.tv_nsec -= NANOSEC; */ \ 256646e55b6Scth ba,a 3b; /* check >= billion again */ \ 2577c478bd9Sstevel@tonic-gate4: 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate ENTRY_NP(gethrestime) 260023e71deSHaik Aftandilian GET_HRESTIME(%o1,%o2,%o3,%o4,%o5,%g1,%g2,%g3,%g4,__LINE__) 2617c478bd9Sstevel@tonic-gate CONV_HRESTIME(%o1, %o2, %o3, %o4, %o5) 2627c478bd9Sstevel@tonic-gate stn %o1, [%o0] 2637c478bd9Sstevel@tonic-gate retl 2641e2e7a75Shuah stn %o2, [%o0 + CLONGSIZE] 2657c478bd9Sstevel@tonic-gate SET_SIZE(gethrestime) 2667c478bd9Sstevel@tonic-gate 2677c478bd9Sstevel@tonic-gate/* 2687c478bd9Sstevel@tonic-gate * Similar to gethrestime(), but gethrestime_sec() returns current hrestime 2697c478bd9Sstevel@tonic-gate * seconds. 2707c478bd9Sstevel@tonic-gate */ 2717c478bd9Sstevel@tonic-gate ENTRY_NP(gethrestime_sec) 272023e71deSHaik Aftandilian GET_HRESTIME(%o0,%o2,%o3,%o4,%o5,%g1,%g2,%g3,%g4,__LINE__) 2737c478bd9Sstevel@tonic-gate CONV_HRESTIME(%o0, %o2, %o3, %o4, %o5) 2747c478bd9Sstevel@tonic-gate retl ! %o0 current hrestime seconds 2751e2e7a75Shuah nop 2767c478bd9Sstevel@tonic-gate SET_SIZE(gethrestime_sec) 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate/* 2797c478bd9Sstevel@tonic-gate * Returns the hrestime on the last tick. This is simpler than gethrestime() 2807c478bd9Sstevel@tonic-gate * and gethrestime_sec(): no conversion is required. gethrestime_lasttick() 2817c478bd9Sstevel@tonic-gate * follows the same locking algorithm as GET_HRESTIME and GET_HRTIME, 2827c478bd9Sstevel@tonic-gate * outlined in detail in clock.h. (Unlike GET_HRESTIME/GET_HRTIME, we don't 2837c478bd9Sstevel@tonic-gate * rely on load dependencies to effect the membar #LoadLoad, instead declaring 2847c478bd9Sstevel@tonic-gate * it explicitly.) 2857c478bd9Sstevel@tonic-gate */ 2867c478bd9Sstevel@tonic-gate ENTRY_NP(gethrestime_lasttick) 2877c478bd9Sstevel@tonic-gate sethi %hi(hres_lock), %o1 2887c478bd9Sstevel@tonic-gate0: 2897c478bd9Sstevel@tonic-gate lduw [%o1 + %lo(hres_lock)], %o2 ! Load lock value 2907c478bd9Sstevel@tonic-gate membar #LoadLoad ! Load of lock must complete 291*5d9d9091SRichard Lowe andn %o2, 1, %o2 ! Mask off lowest bit 2927c478bd9Sstevel@tonic-gate ldn [%o1 + %lo(hrestime)], %g1 ! Seconds. 2937c478bd9Sstevel@tonic-gate add %o1, %lo(hrestime), %o4 2947c478bd9Sstevel@tonic-gate ldn [%o4 + CLONGSIZE], %g2 ! Nanoseconds. 2957c478bd9Sstevel@tonic-gate membar #LoadLoad ! All loads must complete 2967c478bd9Sstevel@tonic-gate lduw [%o1 + %lo(hres_lock)], %o3 ! Reload lock value 2977c478bd9Sstevel@tonic-gate cmp %o3, %o2 ! If lock is locked or has 2987c478bd9Sstevel@tonic-gate bne 0b ! changed, retry. 2991e2e7a75Shuah stn %g1, [%o0] ! Delay: store seconds 3007c478bd9Sstevel@tonic-gate retl 3011e2e7a75Shuah stn %g2, [%o0 + CLONGSIZE] ! Delay: store nanoseconds 3027c478bd9Sstevel@tonic-gate SET_SIZE(gethrestime_lasttick) 3037c478bd9Sstevel@tonic-gate 3047c478bd9Sstevel@tonic-gate/* 3057c478bd9Sstevel@tonic-gate * Fast trap for gettimeofday(). Returns a timestruc_t in %o0 and %o1. 3067c478bd9Sstevel@tonic-gate * 3077c478bd9Sstevel@tonic-gate * This is the handler for the ST_GETHRESTIME trap. 3087c478bd9Sstevel@tonic-gate */ 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate ENTRY_NP(get_hrestime) 311023e71deSHaik Aftandilian GET_HRESTIME(%o0,%o1,%g1,%g2,%g3,%g4,%g5,%o2,%o3,__LINE__) 3127c478bd9Sstevel@tonic-gate CONV_HRESTIME(%o0, %o1, %g1, %g2, %g3) 3137c478bd9Sstevel@tonic-gate FAST_TRAP_DONE 3147c478bd9Sstevel@tonic-gate SET_SIZE(get_hrestime) 3157c478bd9Sstevel@tonic-gate 3167c478bd9Sstevel@tonic-gate/* 3177c478bd9Sstevel@tonic-gate * Fast trap to return lwp virtual time, uses trap window, leaves traps 3187c478bd9Sstevel@tonic-gate * disabled. Returns a 64-bit number in %o0:%o1, which is the number 3197c478bd9Sstevel@tonic-gate * of nanoseconds consumed. 3207c478bd9Sstevel@tonic-gate * 3217c478bd9Sstevel@tonic-gate * This is the handler for the ST_GETHRVTIME trap. 3227c478bd9Sstevel@tonic-gate * 3237c478bd9Sstevel@tonic-gate * Register usage: 3247c478bd9Sstevel@tonic-gate * %o0, %o1 = return lwp virtual time 3257c478bd9Sstevel@tonic-gate * %o2 = CPU/thread 3267c478bd9Sstevel@tonic-gate * %o3 = lwp 3277c478bd9Sstevel@tonic-gate * %g1 = scratch 3287c478bd9Sstevel@tonic-gate * %g5 = scratch 3297c478bd9Sstevel@tonic-gate */ 3307c478bd9Sstevel@tonic-gate ENTRY_NP(get_virtime) 331023e71deSHaik Aftandilian GET_NATIVE_TIME(%g5,%g1,%g2,__LINE__) ! %g5 = native time in ticks 3327c478bd9Sstevel@tonic-gate CPU_ADDR(%g2, %g3) ! CPU struct ptr to %g2 3337c478bd9Sstevel@tonic-gate ldn [%g2 + CPU_THREAD], %g2 ! thread pointer to %g2 3347c478bd9Sstevel@tonic-gate ldn [%g2 + T_LWP], %g3 ! lwp pointer to %g3 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate /* 3377c478bd9Sstevel@tonic-gate * Subtract start time of current microstate from time 3387c478bd9Sstevel@tonic-gate * of day to get increment for lwp virtual time. 3397c478bd9Sstevel@tonic-gate */ 3407c478bd9Sstevel@tonic-gate ldx [%g3 + LWP_STATE_START], %g1 ! ms_state_start 3417c478bd9Sstevel@tonic-gate sub %g5, %g1, %g5 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate /* 3447c478bd9Sstevel@tonic-gate * Add current value of ms_acct[LMS_USER] 3457c478bd9Sstevel@tonic-gate */ 3467c478bd9Sstevel@tonic-gate ldx [%g3 + LWP_ACCT_USER], %g1 ! ms_acct[LMS_USER] 3477c478bd9Sstevel@tonic-gate add %g5, %g1, %g5 348*5d9d9091SRichard Lowe NATIVE_TIME_TO_NSEC(%g5, %g1, %o0) 349*5d9d9091SRichard Lowe 3507c478bd9Sstevel@tonic-gate srl %g5, 0, %o1 ! %o1 = lo32(%g5) 3517c478bd9Sstevel@tonic-gate srlx %g5, 32, %o0 ! %o0 = hi32(%g5) 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate FAST_TRAP_DONE 3547c478bd9Sstevel@tonic-gate SET_SIZE(get_virtime) 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate .seg ".text" 3597c478bd9Sstevel@tonic-gatehrtime_base_panic: 3607c478bd9Sstevel@tonic-gate .asciz "hrtime_base stepping back" 3617c478bd9Sstevel@tonic-gate 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate ENTRY_NP(hres_tick) 3647c478bd9Sstevel@tonic-gate save %sp, -SA(MINFRAME), %sp ! get a new window 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate sethi %hi(hrestime), %l4 3677c478bd9Sstevel@tonic-gate ldstub [%l4 + %lo(hres_lock + HRES_LOCK_OFFSET)], %l5 ! try locking 3687c478bd9Sstevel@tonic-gate7: tst %l5 3697c478bd9Sstevel@tonic-gate bz,pt %xcc, 8f ! if we got it, drive on 3701e2e7a75Shuah ld [%l4 + %lo(nsec_scale)], %l5 ! delay: %l5 = scaling factor 3717c478bd9Sstevel@tonic-gate ldub [%l4 + %lo(hres_lock + HRES_LOCK_OFFSET)], %l5 3727c478bd9Sstevel@tonic-gate9: tst %l5 3737c478bd9Sstevel@tonic-gate bz,a,pn %xcc, 7b 3741e2e7a75Shuah ldstub [%l4 + %lo(hres_lock + HRES_LOCK_OFFSET)], %l5 3757c478bd9Sstevel@tonic-gate ba,pt %xcc, 9b 3761e2e7a75Shuah ldub [%l4 + %lo(hres_lock + HRES_LOCK_OFFSET)], %l5 3777c478bd9Sstevel@tonic-gate8: 3787c478bd9Sstevel@tonic-gate membar #StoreLoad|#StoreStore 3797c478bd9Sstevel@tonic-gate 3807c478bd9Sstevel@tonic-gate ! 3817c478bd9Sstevel@tonic-gate ! update hres_last_tick. %l5 has the scaling factor (nsec_scale). 3827c478bd9Sstevel@tonic-gate ! 3837c478bd9Sstevel@tonic-gate ldx [%l4 + %lo(hrtime_base)], %g1 ! load current hrtime_base 384023e71deSHaik Aftandilian GET_NATIVE_TIME(%l0,%l3,%l6,__LINE__) ! current native time 3857c478bd9Sstevel@tonic-gate stx %l0, [%l4 + %lo(hres_last_tick)]! prev = current 3867c478bd9Sstevel@tonic-gate ! convert native time to nsecs 3877c478bd9Sstevel@tonic-gate NATIVE_TIME_TO_NSEC_SCALE(%l0, %l5, %l2, NSEC_SHIFT) 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate sub %l0, %g1, %i1 ! get accurate nsec delta 3907c478bd9Sstevel@tonic-gate 391*5d9d9091SRichard Lowe ldx [%l4 + %lo(hrtime_base)], %l1 3927c478bd9Sstevel@tonic-gate cmp %l1, %l0 3937c478bd9Sstevel@tonic-gate bg,pn %xcc, 9f 3941e2e7a75Shuah nop 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate stx %l0, [%l4 + %lo(hrtime_base)] ! update hrtime_base 3977c478bd9Sstevel@tonic-gate 3987c478bd9Sstevel@tonic-gate ! 3997c478bd9Sstevel@tonic-gate ! apply adjustment, if any 4007c478bd9Sstevel@tonic-gate ! 4017c478bd9Sstevel@tonic-gate ldx [%l4 + %lo(hrestime_adj)], %l0 ! %l0 = hrestime_adj 4027c478bd9Sstevel@tonic-gate brz %l0, 2f 4037c478bd9Sstevel@tonic-gate ! hrestime_adj == 0 ? 4047c478bd9Sstevel@tonic-gate ! yes, skip adjustments 4051e2e7a75Shuah clr %l5 ! delay: set adj to zero 4067c478bd9Sstevel@tonic-gate tst %l0 ! is hrestime_adj >= 0 ? 4077c478bd9Sstevel@tonic-gate bge,pt %xcc, 1f ! yes, go handle positive case 4081e2e7a75Shuah srl %i1, ADJ_SHIFT, %l5 ! delay: %l5 = adj 4097c478bd9Sstevel@tonic-gate 4107c478bd9Sstevel@tonic-gate addcc %l0, %l5, %g0 ! hrestime_adj < -adj ? 4117c478bd9Sstevel@tonic-gate bl,pt %xcc, 2f ! yes, use current adj 4121e2e7a75Shuah neg %l5 ! delay: %l5 = -adj 4137c478bd9Sstevel@tonic-gate ba,pt %xcc, 2f 4141e2e7a75Shuah mov %l0, %l5 ! no, so set adj = hrestime_adj 4157c478bd9Sstevel@tonic-gate1: 4167c478bd9Sstevel@tonic-gate subcc %l0, %l5, %g0 ! hrestime_adj < adj ? 4177c478bd9Sstevel@tonic-gate bl,a,pt %xcc, 2f ! yes, set adj = hrestime_adj 4181e2e7a75Shuah mov %l0, %l5 ! delay: adj = hrestime_adj 4197c478bd9Sstevel@tonic-gate2: 4207c478bd9Sstevel@tonic-gate ldx [%l4 + %lo(timedelta)], %l0 ! %l0 = timedelta 4217c478bd9Sstevel@tonic-gate sub %l0, %l5, %l0 ! timedelta -= adj 4227c478bd9Sstevel@tonic-gate 4237c478bd9Sstevel@tonic-gate stx %l0, [%l4 + %lo(timedelta)] ! store new timedelta 4247c478bd9Sstevel@tonic-gate stx %l0, [%l4 + %lo(hrestime_adj)] ! hrestime_adj = timedelta 4257c478bd9Sstevel@tonic-gate 4267c478bd9Sstevel@tonic-gate or %l4, %lo(hrestime), %l2 4277c478bd9Sstevel@tonic-gate ldn [%l2], %i2 ! %i2:%i3 = hrestime sec:nsec 4287c478bd9Sstevel@tonic-gate ldn [%l2 + CLONGSIZE], %i3 4297c478bd9Sstevel@tonic-gate add %i3, %l5, %i3 ! hrestime.nsec += adj 4307c478bd9Sstevel@tonic-gate add %i3, %i1, %i3 ! hrestime.nsec += nslt 4317c478bd9Sstevel@tonic-gate 4327c478bd9Sstevel@tonic-gate set NANOSEC, %l5 ! %l5 = NANOSEC 4337c478bd9Sstevel@tonic-gate cmp %i3, %l5 4347c478bd9Sstevel@tonic-gate bl,pt %xcc, 5f ! if hrestime.tv_nsec < NANOSEC 4351e2e7a75Shuah sethi %hi(one_sec), %i1 ! delay 4367c478bd9Sstevel@tonic-gate add %i2, 0x1, %i2 ! hrestime.tv_sec++ 4377c478bd9Sstevel@tonic-gate sub %i3, %l5, %i3 ! hrestime.tv_nsec - NANOSEC 4387c478bd9Sstevel@tonic-gate mov 0x1, %l5 4397c478bd9Sstevel@tonic-gate st %l5, [%i1 + %lo(one_sec)] 4407c478bd9Sstevel@tonic-gate5: 4417c478bd9Sstevel@tonic-gate stn %i2, [%l2] 4427c478bd9Sstevel@tonic-gate stn %i3, [%l2 + CLONGSIZE] ! store the new hrestime 4437c478bd9Sstevel@tonic-gate 4447c478bd9Sstevel@tonic-gate membar #StoreStore 4457c478bd9Sstevel@tonic-gate 4467c478bd9Sstevel@tonic-gate ld [%l4 + %lo(hres_lock)], %i1 4477c478bd9Sstevel@tonic-gate inc %i1 ! release lock 4487c478bd9Sstevel@tonic-gate st %i1, [%l4 + %lo(hres_lock)] ! clear hres_lock 4497c478bd9Sstevel@tonic-gate 4507c478bd9Sstevel@tonic-gate ret 4517c478bd9Sstevel@tonic-gate restore 4527c478bd9Sstevel@tonic-gate 4537c478bd9Sstevel@tonic-gate9: 4547c478bd9Sstevel@tonic-gate ! 4557c478bd9Sstevel@tonic-gate ! release hres_lock 4567c478bd9Sstevel@tonic-gate ! 4577c478bd9Sstevel@tonic-gate ld [%l4 + %lo(hres_lock)], %i1 4587c478bd9Sstevel@tonic-gate inc %i1 4597c478bd9Sstevel@tonic-gate st %i1, [%l4 + %lo(hres_lock)] 4607c478bd9Sstevel@tonic-gate 4617c478bd9Sstevel@tonic-gate sethi %hi(hrtime_base_panic), %o0 4627c478bd9Sstevel@tonic-gate call panic 4631e2e7a75Shuah or %o0, %lo(hrtime_base_panic), %o0 4647c478bd9Sstevel@tonic-gate 4657c478bd9Sstevel@tonic-gate SET_SIZE(hres_tick) 4667c478bd9Sstevel@tonic-gate 4677c478bd9Sstevel@tonic-gate .seg ".text" 4687c478bd9Sstevel@tonic-gatekstat_q_panic_msg: 4697c478bd9Sstevel@tonic-gate .asciz "kstat_q_exit: qlen == 0" 4707c478bd9Sstevel@tonic-gate 4717c478bd9Sstevel@tonic-gate ENTRY(kstat_q_panic) 4727c478bd9Sstevel@tonic-gate save %sp, -SA(MINFRAME), %sp 4737c478bd9Sstevel@tonic-gate sethi %hi(kstat_q_panic_msg), %o0 4747c478bd9Sstevel@tonic-gate call panic 4751e2e7a75Shuah or %o0, %lo(kstat_q_panic_msg), %o0 4767c478bd9Sstevel@tonic-gate /*NOTREACHED*/ 4777c478bd9Sstevel@tonic-gate SET_SIZE(kstat_q_panic) 4787c478bd9Sstevel@tonic-gate 4797c478bd9Sstevel@tonic-gate#define BRZPN brz,pn 4807c478bd9Sstevel@tonic-gate#define BRZPT brz,pt 4817c478bd9Sstevel@tonic-gate 4827c478bd9Sstevel@tonic-gate#define KSTAT_Q_UPDATE(QOP, QBR, QZERO, QRETURN, QTYPE) \ 483*5d9d9091SRichard Lowe ld [%o0 + QTYPE##CNT], %o1; /* %o1 = old qlen */ \ 4847c478bd9Sstevel@tonic-gate QOP %o1, 1, %o2; /* %o2 = new qlen */ \ 4857c478bd9Sstevel@tonic-gate QBR %o1, QZERO; /* done if qlen == 0 */ \ 486*5d9d9091SRichard Lowe st %o2, [%o0 + QTYPE##CNT]; /* delay: save qlen */ \ 487*5d9d9091SRichard Lowe ldx [%o0 + QTYPE##LASTUPDATE], %o3; \ 488*5d9d9091SRichard Lowe ldx [%o0 + QTYPE##TIME], %o4; /* %o4 = old time */ \ 489*5d9d9091SRichard Lowe ldx [%o0 + QTYPE##LENTIME], %o5; /* %o5 = old lentime */ \ 4907c478bd9Sstevel@tonic-gate sub %g1, %o3, %o2; /* %o2 = time delta */ \ 4917c478bd9Sstevel@tonic-gate mulx %o1, %o2, %o3; /* %o3 = cur lentime */ \ 4927c478bd9Sstevel@tonic-gate add %o4, %o2, %o4; /* %o4 = new time */ \ 4937c478bd9Sstevel@tonic-gate add %o5, %o3, %o5; /* %o5 = new lentime */ \ 494*5d9d9091SRichard Lowe stx %o4, [%o0 + QTYPE##TIME]; /* save time */ \ 495*5d9d9091SRichard Lowe stx %o5, [%o0 + QTYPE##LENTIME]; /* save lentime */ \ 4967c478bd9Sstevel@tonic-gateQRETURN; \ 497*5d9d9091SRichard Lowe stx %g1, [%o0 + QTYPE##LASTUPDATE]; /* lastupdate = now */ 4987c478bd9Sstevel@tonic-gate 4996e7bd672SToomas Soome#if !defined(DEBUG) 5006e7bd672SToomas Soome/* 5016e7bd672SToomas Soome * same as KSTAT_Q_UPDATE but without: 5026e7bd672SToomas Soome * QBR %o1, QZERO; 5036e7bd672SToomas Soome * to be used only with non-debug build. mimics ASSERT() behaviour. 5046e7bd672SToomas Soome */ 5056e7bd672SToomas Soome#define KSTAT_Q_UPDATE_ND(QOP, QRETURN, QTYPE) \ 506*5d9d9091SRichard Lowe ld [%o0 + QTYPE##CNT], %o1; /* %o1 = old qlen */ \ 5076e7bd672SToomas Soome QOP %o1, 1, %o2; /* %o2 = new qlen */ \ 508*5d9d9091SRichard Lowe st %o2, [%o0 + QTYPE##CNT]; /* delay: save qlen */ \ 509*5d9d9091SRichard Lowe ldx [%o0 + QTYPE##LASTUPDATE], %o3; \ 510*5d9d9091SRichard Lowe ldx [%o0 + QTYPE##TIME], %o4; /* %o4 = old time */ \ 511*5d9d9091SRichard Lowe ldx [%o0 + QTYPE##LENTIME], %o5; /* %o5 = old lentime */ \ 5126e7bd672SToomas Soome sub %g1, %o3, %o2; /* %o2 = time delta */ \ 5136e7bd672SToomas Soome mulx %o1, %o2, %o3; /* %o3 = cur lentime */ \ 5146e7bd672SToomas Soome add %o4, %o2, %o4; /* %o4 = new time */ \ 5156e7bd672SToomas Soome add %o5, %o3, %o5; /* %o5 = new lentime */ \ 516*5d9d9091SRichard Lowe stx %o4, [%o0 + QTYPE##TIME]; /* save time */ \ 517*5d9d9091SRichard Lowe stx %o5, [%o0 + QTYPE##LENTIME]; /* save lentime */ \ 5186e7bd672SToomas SoomeQRETURN; \ 519*5d9d9091SRichard Lowe stx %g1, [%o0 + QTYPE##LASTUPDATE]; /* lastupdate = now */ 5206e7bd672SToomas Soome#endif 5216e7bd672SToomas Soome 5227c478bd9Sstevel@tonic-gate .align 16 5237c478bd9Sstevel@tonic-gate ENTRY(kstat_waitq_enter) 524023e71deSHaik Aftandilian GET_NATIVE_TIME(%g1,%g2,%g3,__LINE__) 5257c478bd9Sstevel@tonic-gate KSTAT_Q_UPDATE(add, BRZPT, 1f, 1:retl, KSTAT_IO_W) 5267c478bd9Sstevel@tonic-gate SET_SIZE(kstat_waitq_enter) 5277c478bd9Sstevel@tonic-gate 5287c478bd9Sstevel@tonic-gate .align 16 5297c478bd9Sstevel@tonic-gate ENTRY(kstat_waitq_exit) 530023e71deSHaik Aftandilian GET_NATIVE_TIME(%g1,%g2,%g3,__LINE__) 5316e7bd672SToomas Soome#if defined(DEBUG) 5327c478bd9Sstevel@tonic-gate KSTAT_Q_UPDATE(sub, BRZPN, kstat_q_panic, retl, KSTAT_IO_W) 5336e7bd672SToomas Soome#else 5346e7bd672SToomas Soome KSTAT_Q_UPDATE_ND(sub, retl, KSTAT_IO_W) 5356e7bd672SToomas Soome#endif 5367c478bd9Sstevel@tonic-gate SET_SIZE(kstat_waitq_exit) 5377c478bd9Sstevel@tonic-gate 5387c478bd9Sstevel@tonic-gate .align 16 5397c478bd9Sstevel@tonic-gate ENTRY(kstat_runq_enter) 540023e71deSHaik Aftandilian GET_NATIVE_TIME(%g1,%g2,%g3,__LINE__) 5417c478bd9Sstevel@tonic-gate KSTAT_Q_UPDATE(add, BRZPT, 1f, 1:retl, KSTAT_IO_R) 5427c478bd9Sstevel@tonic-gate SET_SIZE(kstat_runq_enter) 5437c478bd9Sstevel@tonic-gate 5447c478bd9Sstevel@tonic-gate .align 16 5457c478bd9Sstevel@tonic-gate ENTRY(kstat_runq_exit) 546023e71deSHaik Aftandilian GET_NATIVE_TIME(%g1,%g2,%g3,__LINE__) 5476e7bd672SToomas Soome#if defined(DEBUG) 5487c478bd9Sstevel@tonic-gate KSTAT_Q_UPDATE(sub, BRZPN, kstat_q_panic, retl, KSTAT_IO_R) 5496e7bd672SToomas Soome#else 5506e7bd672SToomas Soome KSTAT_Q_UPDATE_ND(sub, retl, KSTAT_IO_R) 5516e7bd672SToomas Soome#endif 5527c478bd9Sstevel@tonic-gate SET_SIZE(kstat_runq_exit) 5537c478bd9Sstevel@tonic-gate 5547c478bd9Sstevel@tonic-gate .align 16 5557c478bd9Sstevel@tonic-gate ENTRY(kstat_waitq_to_runq) 556023e71deSHaik Aftandilian GET_NATIVE_TIME(%g1,%g2,%g3,__LINE__) 5576e7bd672SToomas Soome#if defined(DEBUG) 5587c478bd9Sstevel@tonic-gate KSTAT_Q_UPDATE(sub, BRZPN, kstat_q_panic, 1:, KSTAT_IO_W) 5596e7bd672SToomas Soome#else 5606e7bd672SToomas Soome KSTAT_Q_UPDATE_ND(sub, 1:, KSTAT_IO_W) 5616e7bd672SToomas Soome#endif 5627c478bd9Sstevel@tonic-gate KSTAT_Q_UPDATE(add, BRZPT, 1f, 1:retl, KSTAT_IO_R) 5637c478bd9Sstevel@tonic-gate SET_SIZE(kstat_waitq_to_runq) 5647c478bd9Sstevel@tonic-gate 5657c478bd9Sstevel@tonic-gate .align 16 5667c478bd9Sstevel@tonic-gate ENTRY(kstat_runq_back_to_waitq) 567023e71deSHaik Aftandilian GET_NATIVE_TIME(%g1,%g2,%g3,__LINE__) 5686e7bd672SToomas Soome#if defined(DEBUG) 5697c478bd9Sstevel@tonic-gate KSTAT_Q_UPDATE(sub, BRZPN, kstat_q_panic, 1:, KSTAT_IO_R) 5706e7bd672SToomas Soome#else 5716e7bd672SToomas Soome KSTAT_Q_UPDATE_ND(sub, 1:, KSTAT_IO_R) 5726e7bd672SToomas Soome#endif 5737c478bd9Sstevel@tonic-gate KSTAT_Q_UPDATE(add, BRZPT, 1f, 1:retl, KSTAT_IO_W) 5747c478bd9Sstevel@tonic-gate SET_SIZE(kstat_runq_back_to_waitq) 5757c478bd9Sstevel@tonic-gate 5767c478bd9Sstevel@tonic-gate /* 5777c478bd9Sstevel@tonic-gate * -- WARNING -- 5787c478bd9Sstevel@tonic-gate * 5797c478bd9Sstevel@tonic-gate * The following variables MUST be together on a 128-byte boundary. 5807c478bd9Sstevel@tonic-gate * In addition to the primary performance motivation (having them all 5817c478bd9Sstevel@tonic-gate * on the same cache line(s)), code here and in the GET*TIME() macros 5827c478bd9Sstevel@tonic-gate * assumes that they all have the same high 22 address bits (so 5837c478bd9Sstevel@tonic-gate * there's only one sethi). 5847c478bd9Sstevel@tonic-gate */ 5857c478bd9Sstevel@tonic-gate .seg ".data" 5867c478bd9Sstevel@tonic-gate .global timedelta, hres_last_tick, hrestime, hrestime_adj 5877c478bd9Sstevel@tonic-gate .global hres_lock, nsec_scale, hrtime_base, traptrace_use_stick 588023e71deSHaik Aftandilian .global nsec_shift, adj_shift, native_tick_offset, native_stick_offset 5897c478bd9Sstevel@tonic-gate 5907c478bd9Sstevel@tonic-gate /* XXX - above comment claims 128-bytes is necessary */ 5917c478bd9Sstevel@tonic-gate .align 64 5927c478bd9Sstevel@tonic-gatetimedelta: 5937c478bd9Sstevel@tonic-gate .word 0, 0 /* int64_t */ 5947c478bd9Sstevel@tonic-gatehres_last_tick: 5957c478bd9Sstevel@tonic-gate .word 0, 0 /* hrtime_t */ 5967c478bd9Sstevel@tonic-gatehrestime: 5977c478bd9Sstevel@tonic-gate .nword 0, 0 /* 2 longs */ 5987c478bd9Sstevel@tonic-gatehrestime_adj: 5997c478bd9Sstevel@tonic-gate .word 0, 0 /* int64_t */ 6007c478bd9Sstevel@tonic-gatehres_lock: 6017c478bd9Sstevel@tonic-gate .word 0 6027c478bd9Sstevel@tonic-gatensec_scale: 6037c478bd9Sstevel@tonic-gate .word 0 6047c478bd9Sstevel@tonic-gatehrtime_base: 6057c478bd9Sstevel@tonic-gate .word 0, 0 6067c478bd9Sstevel@tonic-gatetraptrace_use_stick: 6077c478bd9Sstevel@tonic-gate .word 0 6087c478bd9Sstevel@tonic-gatensec_shift: 6097c478bd9Sstevel@tonic-gate .word NSEC_SHIFT 6107c478bd9Sstevel@tonic-gateadj_shift: 6117c478bd9Sstevel@tonic-gate .word ADJ_SHIFT 612023e71deSHaik Aftandilian .align 8 613023e71deSHaik Aftandiliannative_tick_offset: 614023e71deSHaik Aftandilian .word 0, 0 615023e71deSHaik Aftandilian .align 8 616023e71deSHaik Aftandiliannative_stick_offset: 617023e71deSHaik Aftandilian .word 0, 0 6187c478bd9Sstevel@tonic-gate 6197c478bd9Sstevel@tonic-gate 6207c478bd9Sstevel@tonic-gate/* 6217c478bd9Sstevel@tonic-gate * drv_usecwait(clock_t n) [DDI/DKI - section 9F] 6227c478bd9Sstevel@tonic-gate * usec_delay(int n) [compatibility - should go one day] 6237c478bd9Sstevel@tonic-gate * Delay by spinning. 6247c478bd9Sstevel@tonic-gate * 6257c478bd9Sstevel@tonic-gate * delay for n microseconds. numbers <= 0 delay 1 usec 6267c478bd9Sstevel@tonic-gate * 6277c478bd9Sstevel@tonic-gate * With UltraSPARC-III the combination of supporting mixed-speed CPUs 6287c478bd9Sstevel@tonic-gate * and variable clock rate for power management requires that we 6297c478bd9Sstevel@tonic-gate * use %stick to implement this routine. 6307c478bd9Sstevel@tonic-gate */ 6317c478bd9Sstevel@tonic-gate 6327c478bd9Sstevel@tonic-gate ENTRY(drv_usecwait) 6337c478bd9Sstevel@tonic-gate ALTENTRY(usec_delay) 6347c478bd9Sstevel@tonic-gate brlez,a,pn %o0, 0f 6351e2e7a75Shuah mov 1, %o0 6367c478bd9Sstevel@tonic-gate0: 6377c478bd9Sstevel@tonic-gate sethi %hi(sticks_per_usec), %o1 6387c478bd9Sstevel@tonic-gate lduw [%o1 + %lo(sticks_per_usec)], %o1 6397c478bd9Sstevel@tonic-gate mulx %o1, %o0, %o1 ! Scale usec to ticks 6407c478bd9Sstevel@tonic-gate inc %o1 ! We don't start on a tick edge 641023e71deSHaik Aftandilian GET_NATIVE_TIME(%o2,%o3,%o4,__LINE__) 6427c478bd9Sstevel@tonic-gate add %o1, %o2, %o1 6437c478bd9Sstevel@tonic-gate 6447c478bd9Sstevel@tonic-gate1: cmp %o1, %o2 645023e71deSHaik Aftandilian GET_NATIVE_TIME(%o2,%o3,%o4,__LINE__) 6467c478bd9Sstevel@tonic-gate bgeu,pt %xcc, 1b 6471e2e7a75Shuah nop 6487c478bd9Sstevel@tonic-gate retl 6491e2e7a75Shuah nop 6507c478bd9Sstevel@tonic-gate SET_SIZE(usec_delay) 6517c478bd9Sstevel@tonic-gate SET_SIZE(drv_usecwait) 6527c478bd9Sstevel@tonic-gate 6537c478bd9Sstevel@tonic-gate/* 6547c478bd9Sstevel@tonic-gate * Level-14 interrupt prologue. 6557c478bd9Sstevel@tonic-gate */ 6567c478bd9Sstevel@tonic-gate ENTRY_NP(pil14_interrupt) 6577c478bd9Sstevel@tonic-gate CPU_ADDR(%g1, %g2) 6587c478bd9Sstevel@tonic-gate rdpr %pil, %g6 ! %g6 = interrupted PIL 6597c478bd9Sstevel@tonic-gate stn %g6, [%g1 + CPU_PROFILE_PIL] ! record interrupted PIL 6607c478bd9Sstevel@tonic-gate rdpr %tstate, %g6 6617c478bd9Sstevel@tonic-gate rdpr %tpc, %g5 6627c478bd9Sstevel@tonic-gate btst TSTATE_PRIV, %g6 ! trap from supervisor mode? 6637c478bd9Sstevel@tonic-gate bnz,a,pt %xcc, 1f 6641e2e7a75Shuah stn %g5, [%g1 + CPU_PROFILE_PC] ! if so, record kernel PC 6657c478bd9Sstevel@tonic-gate stn %g5, [%g1 + CPU_PROFILE_UPC] ! if not, record user PC 6667c478bd9Sstevel@tonic-gate ba pil_interrupt_common ! must be large-disp branch 6671e2e7a75Shuah stn %g0, [%g1 + CPU_PROFILE_PC] ! zero kernel PC 6687c478bd9Sstevel@tonic-gate1: ba pil_interrupt_common ! must be large-disp branch 6691e2e7a75Shuah stn %g0, [%g1 + CPU_PROFILE_UPC] ! zero user PC 6707c478bd9Sstevel@tonic-gate SET_SIZE(pil14_interrupt) 6717c478bd9Sstevel@tonic-gate 6727c478bd9Sstevel@tonic-gate ENTRY_NP(tick_rtt) 6737c478bd9Sstevel@tonic-gate ! 6747c478bd9Sstevel@tonic-gate ! Load TICK_COMPARE into %o5; if bit 63 is set, then TICK_COMPARE is 6757c478bd9Sstevel@tonic-gate ! disabled. If TICK_COMPARE is enabled, we know that we need to 6767c478bd9Sstevel@tonic-gate ! reenqueue the interrupt request structure. We'll then check TICKINT 6777c478bd9Sstevel@tonic-gate ! in SOFTINT; if it's set, then we know that we were in a TICK_COMPARE 6787c478bd9Sstevel@tonic-gate ! interrupt. In this case, TICK_COMPARE may have been rewritten 6797c478bd9Sstevel@tonic-gate ! recently; we'll compare %o5 to the current time to verify that it's 680*5d9d9091SRichard Lowe ! in the future. 6817c478bd9Sstevel@tonic-gate ! 6827c478bd9Sstevel@tonic-gate ! Note that %o5 is live until after 1f. 6837c478bd9Sstevel@tonic-gate ! XXX - there is a subroutine call while %o5 is live! 6847c478bd9Sstevel@tonic-gate ! 685023e71deSHaik Aftandilian RD_TICKCMPR(%o5,%g1,%g2,__LINE__) 6867c478bd9Sstevel@tonic-gate srlx %o5, TICKINT_DIS_SHFT, %g1 6877c478bd9Sstevel@tonic-gate brnz,pt %g1, 2f 6881e2e7a75Shuah nop 6897c478bd9Sstevel@tonic-gate 6907c478bd9Sstevel@tonic-gate rdpr %pstate, %g5 6917c478bd9Sstevel@tonic-gate andn %g5, PSTATE_IE, %g1 6927c478bd9Sstevel@tonic-gate wrpr %g0, %g1, %pstate ! Disable vec interrupts 6937c478bd9Sstevel@tonic-gate 6947c478bd9Sstevel@tonic-gate sethi %hi(cbe_level14_inum), %o1 695b0fc0e77Sgovinda ldx [%o1 + %lo(cbe_level14_inum)], %o1 6967c478bd9Sstevel@tonic-gate call intr_enqueue_req ! preserves %o5 and %g5 6971e2e7a75Shuah mov PIL_14, %o0 6987c478bd9Sstevel@tonic-gate 6997c478bd9Sstevel@tonic-gate ! Check SOFTINT for TICKINT/STICKINT 7007c478bd9Sstevel@tonic-gate rd SOFTINT, %o4 7017c478bd9Sstevel@tonic-gate set (TICK_INT_MASK | STICK_INT_MASK), %o0 7027c478bd9Sstevel@tonic-gate andcc %o4, %o0, %g0 7037c478bd9Sstevel@tonic-gate bz,a,pn %icc, 2f 7041e2e7a75Shuah wrpr %g0, %g5, %pstate ! Enable vec interrupts 7057c478bd9Sstevel@tonic-gate 7067c478bd9Sstevel@tonic-gate ! clear TICKINT/STICKINT 7077c478bd9Sstevel@tonic-gate wr %o0, CLEAR_SOFTINT 7087c478bd9Sstevel@tonic-gate 7097c478bd9Sstevel@tonic-gate ! 7107c478bd9Sstevel@tonic-gate ! Now that we've cleared TICKINT, we can reread %tick and confirm 7117c478bd9Sstevel@tonic-gate ! that the value we programmed is still in the future. If it isn't, 7127c478bd9Sstevel@tonic-gate ! we need to reprogram TICK_COMPARE to fire as soon as possible. 7137c478bd9Sstevel@tonic-gate ! 714023e71deSHaik Aftandilian GET_NATIVE_TIME(%o0,%g1,%g2,__LINE__) ! %o0 = tick 7157c478bd9Sstevel@tonic-gate cmp %o5, %o0 ! In the future? 7167c478bd9Sstevel@tonic-gate bg,a,pt %xcc, 2f ! Yes, drive on. 7171e2e7a75Shuah wrpr %g0, %g5, %pstate ! delay: enable vec intr 7187c478bd9Sstevel@tonic-gate 7197c478bd9Sstevel@tonic-gate ! 7207c478bd9Sstevel@tonic-gate ! If we're here, then we have programmed TICK_COMPARE with a %tick 7217c478bd9Sstevel@tonic-gate ! which is in the past; we'll now load an initial step size, and loop 7227c478bd9Sstevel@tonic-gate ! until we've managed to program TICK_COMPARE to fire in the future. 7237c478bd9Sstevel@tonic-gate ! 7247c478bd9Sstevel@tonic-gate mov 8, %o4 ! 8 = arbitrary inital step 7257c478bd9Sstevel@tonic-gate1: add %o0, %o4, %o5 ! Add the step 7267c478bd9Sstevel@tonic-gate WR_TICKCMPR(%o5,%g1,%g2,__LINE__) ! Write to TICK_CMPR 727023e71deSHaik Aftandilian GET_NATIVE_TIME(%o0,%g1,%g2,__LINE__) ! %o0 = tick 7287c478bd9Sstevel@tonic-gate cmp %o5, %o0 ! In the future? 7297c478bd9Sstevel@tonic-gate bg,a,pt %xcc, 2f ! Yes, drive on. 7301e2e7a75Shuah wrpr %g0, %g5, %pstate ! delay: enable vec intr 7317c478bd9Sstevel@tonic-gate ba 1b ! No, try again. 7321e2e7a75Shuah sllx %o4, 1, %o4 ! delay: double step size 7337c478bd9Sstevel@tonic-gate 7347c478bd9Sstevel@tonic-gate2: ba current_thread_complete 7351e2e7a75Shuah nop 7367c478bd9Sstevel@tonic-gate SET_SIZE(tick_rtt) 7377c478bd9Sstevel@tonic-gate 738b9e93c10SJonathan Haslam/* 739b9e93c10SJonathan Haslam * Level-15 interrupt prologue. 740b9e93c10SJonathan Haslam */ 741b9e93c10SJonathan Haslam ENTRY_NP(pil15_interrupt) 742b9e93c10SJonathan Haslam CPU_ADDR(%g1, %g2) 743b9e93c10SJonathan Haslam rdpr %tstate, %g6 744b9e93c10SJonathan Haslam rdpr %tpc, %g5 745b9e93c10SJonathan Haslam btst TSTATE_PRIV, %g6 ! trap from supervisor mode? 746b9e93c10SJonathan Haslam bnz,a,pt %xcc, 1f 747b9e93c10SJonathan Haslam stn %g5, [%g1 + CPU_CPCPROFILE_PC] ! if so, record kernel PC 748b9e93c10SJonathan Haslam stn %g5, [%g1 + CPU_CPCPROFILE_UPC] ! if not, record user PC 749b9e93c10SJonathan Haslam ba pil15_epilogue ! must be large-disp branch 750b9e93c10SJonathan Haslam stn %g0, [%g1 + CPU_CPCPROFILE_PC] ! zero kernel PC 751b9e93c10SJonathan Haslam1: ba pil15_epilogue ! must be large-disp branch 752b9e93c10SJonathan Haslam stn %g0, [%g1 + CPU_CPCPROFILE_UPC] ! zero user PC 753b9e93c10SJonathan Haslam SET_SIZE(pil15_interrupt) 754b9e93c10SJonathan Haslam 7557c478bd9Sstevel@tonic-gate/* 7567c478bd9Sstevel@tonic-gate * Prefetch a page_t for write or read, this assumes a linear 7577c478bd9Sstevel@tonic-gate * scan of sequential page_t's. 7587c478bd9Sstevel@tonic-gate */ 7597c478bd9Sstevel@tonic-gate/* XXXQ These should be inline templates, not functions */ 7607c478bd9Sstevel@tonic-gate ENTRY(prefetch_page_w) 7617c478bd9Sstevel@tonic-gate retl 7621e2e7a75Shuah nop 7637c478bd9Sstevel@tonic-gate SET_SIZE(prefetch_page_w) 7647c478bd9Sstevel@tonic-gate 7657c478bd9Sstevel@tonic-gate ENTRY(prefetch_page_r) 7667c478bd9Sstevel@tonic-gate retl 7671e2e7a75Shuah nop 7687c478bd9Sstevel@tonic-gate SET_SIZE(prefetch_page_r) 7697c478bd9Sstevel@tonic-gate 7707c478bd9Sstevel@tonic-gate/* 7719b0bb795SJohn Levon * Prefetch struct smap for write. 7727c478bd9Sstevel@tonic-gate */ 7737c478bd9Sstevel@tonic-gate/* XXXQ These should be inline templates, not functions */ 7747c478bd9Sstevel@tonic-gate ENTRY(prefetch_smap_w) 7757c478bd9Sstevel@tonic-gate retl 7761e2e7a75Shuah nop 7777c478bd9Sstevel@tonic-gate SET_SIZE(prefetch_smap_w) 7787c478bd9Sstevel@tonic-gate 7797c478bd9Sstevel@tonic-gate/* 7807c478bd9Sstevel@tonic-gate * Generic sun4v MMU and Cache operations. 7817c478bd9Sstevel@tonic-gate */ 7827c478bd9Sstevel@tonic-gate 7837c478bd9Sstevel@tonic-gate ENTRY_NP(vtag_flushpage) 7847c478bd9Sstevel@tonic-gate /* 7857c478bd9Sstevel@tonic-gate * flush page from the tlb 7867c478bd9Sstevel@tonic-gate * 7877c478bd9Sstevel@tonic-gate * %o0 = vaddr 7881e2e7a75Shuah * %o1 = sfmmup 7897c478bd9Sstevel@tonic-gate */ 7901e2e7a75Shuah SFMMU_CPU_CNUM(%o1, %g1, %g2) /* %g1 = sfmmu cnum on this CPU */ 7911e2e7a75Shuah 792*5d9d9091SRichard Lowe mov %g1, %o1 7937c478bd9Sstevel@tonic-gate mov MAP_ITLB | MAP_DTLB, %o2 7947c478bd9Sstevel@tonic-gate ta MMU_UNMAP_ADDR 7957c478bd9Sstevel@tonic-gate brz,pt %o0, 1f 7961e2e7a75Shuah nop 7977c478bd9Sstevel@tonic-gate ba panic_bad_hcall 7981e2e7a75Shuah mov MMU_UNMAP_ADDR, %o1 7997c478bd9Sstevel@tonic-gate1: 8007c478bd9Sstevel@tonic-gate retl 8017c478bd9Sstevel@tonic-gate nop 8021e2e7a75Shuah SET_SIZE(vtag_flushpage) 8037c478bd9Sstevel@tonic-gate 8047c478bd9Sstevel@tonic-gate ENTRY_NP(vtag_flushall) 8057c478bd9Sstevel@tonic-gate mov %g0, %o0 ! XXX no cpu list yet 8067c478bd9Sstevel@tonic-gate mov %g0, %o1 ! XXX no cpu list yet 8077c478bd9Sstevel@tonic-gate mov MAP_ITLB | MAP_DTLB, %o2 8087c478bd9Sstevel@tonic-gate mov MMU_DEMAP_ALL, %o5 8097c478bd9Sstevel@tonic-gate ta FAST_TRAP 8107c478bd9Sstevel@tonic-gate brz,pt %o0, 1f 8111e2e7a75Shuah nop 8127c478bd9Sstevel@tonic-gate ba panic_bad_hcall 8131e2e7a75Shuah mov MMU_DEMAP_ALL, %o1 8147c478bd9Sstevel@tonic-gate1: 8157c478bd9Sstevel@tonic-gate retl 8161e2e7a75Shuah nop 8177c478bd9Sstevel@tonic-gate SET_SIZE(vtag_flushall) 8187c478bd9Sstevel@tonic-gate 8197c478bd9Sstevel@tonic-gate ENTRY_NP(vtag_unmap_perm_tl1) 8207c478bd9Sstevel@tonic-gate /* 8217c478bd9Sstevel@tonic-gate * x-trap to unmap perm map entry 8227c478bd9Sstevel@tonic-gate * %g1 = vaddr 8231e2e7a75Shuah * %g2 = ctxnum (KCONTEXT only) 8247c478bd9Sstevel@tonic-gate */ 8257c478bd9Sstevel@tonic-gate mov %o0, %g3 8267c478bd9Sstevel@tonic-gate mov %o1, %g4 8277c478bd9Sstevel@tonic-gate mov %o2, %g5 8287c478bd9Sstevel@tonic-gate mov %o5, %g6 8297c478bd9Sstevel@tonic-gate mov %g1, %o0 8307c478bd9Sstevel@tonic-gate mov %g2, %o1 8317c478bd9Sstevel@tonic-gate mov MAP_ITLB | MAP_DTLB, %o2 8327c478bd9Sstevel@tonic-gate mov UNMAP_PERM_ADDR, %o5 8337c478bd9Sstevel@tonic-gate ta FAST_TRAP 8347c478bd9Sstevel@tonic-gate brz,pt %o0, 1f 8357c478bd9Sstevel@tonic-gate nop 8361ae08745Sheppo 8377c478bd9Sstevel@tonic-gate mov PTL1_BAD_HCALL, %g1 8381ae08745Sheppo 8391ae08745Sheppo cmp %o0, H_ENOMAP 8401ae08745Sheppo move %xcc, PTL1_BAD_HCALL_UNMAP_PERM_ENOMAP, %g1 841*5d9d9091SRichard Lowe 842*5d9d9091SRichard Lowe cmp %o0, H_EINVAL 8431ae08745Sheppo move %xcc, PTL1_BAD_HCALL_UNMAP_PERM_EINVAL, %g1 8441ae08745Sheppo 8451ae08745Sheppo ba,a ptl1_panic 8467c478bd9Sstevel@tonic-gate1: 8477c478bd9Sstevel@tonic-gate mov %g6, %o5 8487c478bd9Sstevel@tonic-gate mov %g5, %o2 8497c478bd9Sstevel@tonic-gate mov %g4, %o1 8507c478bd9Sstevel@tonic-gate mov %g3, %o0 8517c478bd9Sstevel@tonic-gate retry 8527c478bd9Sstevel@tonic-gate SET_SIZE(vtag_unmap_perm_tl1) 8537c478bd9Sstevel@tonic-gate 8547c478bd9Sstevel@tonic-gate ENTRY_NP(vtag_flushpage_tl1) 8557c478bd9Sstevel@tonic-gate /* 8567c478bd9Sstevel@tonic-gate * x-trap to flush page from tlb and tsb 8577c478bd9Sstevel@tonic-gate * 8587c478bd9Sstevel@tonic-gate * %g1 = vaddr, zero-extended on 32-bit kernel 8591e2e7a75Shuah * %g2 = sfmmup 8607c478bd9Sstevel@tonic-gate * 8617c478bd9Sstevel@tonic-gate * assumes TSBE_TAG = 0 8627c478bd9Sstevel@tonic-gate */ 8637c478bd9Sstevel@tonic-gate srln %g1, MMU_PAGESHIFT, %g1 8647c478bd9Sstevel@tonic-gate slln %g1, MMU_PAGESHIFT, %g1 /* g1 = vaddr */ 8657c478bd9Sstevel@tonic-gate mov %o0, %g3 8667c478bd9Sstevel@tonic-gate mov %o1, %g4 8677c478bd9Sstevel@tonic-gate mov %o2, %g5 8681e2e7a75Shuah mov %g1, %o0 /* vaddr */ 8691e2e7a75Shuah 8701e2e7a75Shuah SFMMU_CPU_CNUM(%g2, %o1, %g6) /* %o1 = sfmmu cnum on this CPU */ 8711e2e7a75Shuah 8727c478bd9Sstevel@tonic-gate mov MAP_ITLB | MAP_DTLB, %o2 8737c478bd9Sstevel@tonic-gate ta MMU_UNMAP_ADDR 8747c478bd9Sstevel@tonic-gate brz,pt %o0, 1f 8757c478bd9Sstevel@tonic-gate nop 8761e2e7a75Shuah ba ptl1_panic 8777c478bd9Sstevel@tonic-gate mov PTL1_BAD_HCALL, %g1 8787c478bd9Sstevel@tonic-gate1: 8797c478bd9Sstevel@tonic-gate mov %g5, %o2 8807c478bd9Sstevel@tonic-gate mov %g4, %o1 8817c478bd9Sstevel@tonic-gate mov %g3, %o0 8827c478bd9Sstevel@tonic-gate membar #Sync 8837c478bd9Sstevel@tonic-gate retry 8847c478bd9Sstevel@tonic-gate SET_SIZE(vtag_flushpage_tl1) 8857c478bd9Sstevel@tonic-gate 8867c478bd9Sstevel@tonic-gate ENTRY_NP(vtag_flush_pgcnt_tl1) 8877c478bd9Sstevel@tonic-gate /* 8887c478bd9Sstevel@tonic-gate * x-trap to flush pgcnt MMU_PAGESIZE pages from tlb 8897c478bd9Sstevel@tonic-gate * 8907c478bd9Sstevel@tonic-gate * %g1 = vaddr, zero-extended on 32-bit kernel 8911e2e7a75Shuah * %g2 = <sfmmup58|pgcnt6>, (pgcnt - 1) is pass'ed in via pgcnt6 bits. 8927c478bd9Sstevel@tonic-gate * 8937c478bd9Sstevel@tonic-gate * NOTE: this handler relies on the fact that no 8947c478bd9Sstevel@tonic-gate * interrupts or traps can occur during the loop 8957c478bd9Sstevel@tonic-gate * issuing the TLB_DEMAP operations. It is assumed 8967c478bd9Sstevel@tonic-gate * that interrupts are disabled and this code is 8977c478bd9Sstevel@tonic-gate * fetching from the kernel locked text address. 8987c478bd9Sstevel@tonic-gate * 8997c478bd9Sstevel@tonic-gate * assumes TSBE_TAG = 0 9007c478bd9Sstevel@tonic-gate */ 9017c478bd9Sstevel@tonic-gate srln %g1, MMU_PAGESHIFT, %g1 9027c478bd9Sstevel@tonic-gate slln %g1, MMU_PAGESHIFT, %g1 /* g1 = vaddr */ 9037c478bd9Sstevel@tonic-gate mov %o0, %g3 9047c478bd9Sstevel@tonic-gate mov %o1, %g4 9057c478bd9Sstevel@tonic-gate mov %o2, %g5 9067c478bd9Sstevel@tonic-gate 9071e2e7a75Shuah and %g2, SFMMU_PGCNT_MASK, %g7 /* g7 = pgcnt - 1 */ 9081e2e7a75Shuah add %g7, 1, %g7 /* g7 = pgcnt */ 9097c478bd9Sstevel@tonic-gate 9101e2e7a75Shuah andn %g2, SFMMU_PGCNT_MASK, %o0 /* %o0 = sfmmup */ 9111e2e7a75Shuah 9121e2e7a75Shuah SFMMU_CPU_CNUM(%o0, %g2, %g6) /* %g2 = sfmmu cnum on this CPU */ 9131e2e7a75Shuah 9141e2e7a75Shuah set MMU_PAGESIZE, %g6 /* g6 = pgsize */ 9151e2e7a75Shuah 916*5d9d9091SRichard Lowe1: 9171e2e7a75Shuah mov %g1, %o0 /* vaddr */ 9181e2e7a75Shuah mov %g2, %o1 /* cnum */ 9197c478bd9Sstevel@tonic-gate mov MAP_ITLB | MAP_DTLB, %o2 9207c478bd9Sstevel@tonic-gate ta MMU_UNMAP_ADDR 9217c478bd9Sstevel@tonic-gate brz,pt %o0, 2f 9221e2e7a75Shuah nop 9237c478bd9Sstevel@tonic-gate ba ptl1_panic 9241e2e7a75Shuah mov PTL1_BAD_HCALL, %g1 9257c478bd9Sstevel@tonic-gate2: 9267c478bd9Sstevel@tonic-gate deccc %g7 /* decr pgcnt */ 9277c478bd9Sstevel@tonic-gate bnz,pt %icc,1b 9281e2e7a75Shuah add %g1, %g6, %g1 /* go to nextpage */ 9297c478bd9Sstevel@tonic-gate 9307c478bd9Sstevel@tonic-gate mov %g5, %o2 9317c478bd9Sstevel@tonic-gate mov %g4, %o1 9327c478bd9Sstevel@tonic-gate mov %g3, %o0 9337c478bd9Sstevel@tonic-gate membar #Sync 9347c478bd9Sstevel@tonic-gate retry 9357c478bd9Sstevel@tonic-gate SET_SIZE(vtag_flush_pgcnt_tl1) 9367c478bd9Sstevel@tonic-gate 9377c478bd9Sstevel@tonic-gate ! Not implemented on US1/US2 9387c478bd9Sstevel@tonic-gate ENTRY_NP(vtag_flushall_tl1) 9397c478bd9Sstevel@tonic-gate mov %o0, %g3 9407c478bd9Sstevel@tonic-gate mov %o1, %g4 9417c478bd9Sstevel@tonic-gate mov %o2, %g5 9427c478bd9Sstevel@tonic-gate mov %o3, %g6 ! XXXQ not used? 9437c478bd9Sstevel@tonic-gate mov %o5, %g7 9447c478bd9Sstevel@tonic-gate mov %g0, %o0 ! XXX no cpu list yet 9457c478bd9Sstevel@tonic-gate mov %g0, %o1 ! XXX no cpu list yet 9467c478bd9Sstevel@tonic-gate mov MAP_ITLB | MAP_DTLB, %o2 9477c478bd9Sstevel@tonic-gate mov MMU_DEMAP_ALL, %o5 9487c478bd9Sstevel@tonic-gate ta FAST_TRAP 9497c478bd9Sstevel@tonic-gate brz,pt %o0, 1f 9501e2e7a75Shuah nop 9517c478bd9Sstevel@tonic-gate ba ptl1_panic 9521e2e7a75Shuah mov PTL1_BAD_HCALL, %g1 9537c478bd9Sstevel@tonic-gate1: 9547c478bd9Sstevel@tonic-gate mov %g7, %o5 9557c478bd9Sstevel@tonic-gate mov %g6, %o3 ! XXXQ not used? 9567c478bd9Sstevel@tonic-gate mov %g5, %o2 9577c478bd9Sstevel@tonic-gate mov %g4, %o1 9587c478bd9Sstevel@tonic-gate mov %g3, %o0 9597c478bd9Sstevel@tonic-gate retry 9607c478bd9Sstevel@tonic-gate SET_SIZE(vtag_flushall_tl1) 9617c478bd9Sstevel@tonic-gate 9627c478bd9Sstevel@tonic-gate/* 9637c478bd9Sstevel@tonic-gate * flush_instr_mem: 9647c478bd9Sstevel@tonic-gate * Flush a portion of the I-$ starting at vaddr 9657c478bd9Sstevel@tonic-gate * %o0 vaddr 9667c478bd9Sstevel@tonic-gate * %o1 bytes to be flushed 9677c478bd9Sstevel@tonic-gate */ 9687c478bd9Sstevel@tonic-gate 9697c478bd9Sstevel@tonic-gate ENTRY(flush_instr_mem) 9707c478bd9Sstevel@tonic-gate membar #StoreStore ! Ensure the stores 9717c478bd9Sstevel@tonic-gate ! are globally visible 9727c478bd9Sstevel@tonic-gate1: 9737c478bd9Sstevel@tonic-gate flush %o0 9747c478bd9Sstevel@tonic-gate subcc %o1, ICACHE_FLUSHSZ, %o1 ! bytes = bytes-0x20 9757c478bd9Sstevel@tonic-gate bgu,pt %ncc, 1b 9761e2e7a75Shuah add %o0, ICACHE_FLUSHSZ, %o0 ! vaddr = vaddr+0x20 9777c478bd9Sstevel@tonic-gate 9787c478bd9Sstevel@tonic-gate retl 9791e2e7a75Shuah nop 9807c478bd9Sstevel@tonic-gate SET_SIZE(flush_instr_mem) 9817c478bd9Sstevel@tonic-gate 9822f0fcb93SJason Beloro#if !defined(CUSTOM_FPZERO) 9832f0fcb93SJason Beloro 9847bafd143Sjb/* 9857bafd143Sjb * fp_zero() - clear all fp data registers and the fsr 9867bafd143Sjb */ 9877bafd143Sjb 9887bafd143Sjb.global fp_zero_zero 9897bafd143Sjb.align 8 9907bafd143Sjbfp_zero_zero: 9917bafd143Sjb .xword 0 9927bafd143Sjb 9937bafd143Sjb ENTRY_NP(fp_zero) 9947bafd143Sjb sethi %hi(fp_zero_zero), %o0 9952f0fcb93SJason Beloro ldx [%o0 + %lo(fp_zero_zero)], %fsr 9967bafd143Sjb ldd [%o0 + %lo(fp_zero_zero)], %f0 9977bafd143Sjb fmovd %f0, %f2 9987bafd143Sjb fmovd %f0, %f4 9997bafd143Sjb fmovd %f0, %f6 10007bafd143Sjb fmovd %f0, %f8 10017bafd143Sjb fmovd %f0, %f10 10027bafd143Sjb fmovd %f0, %f12 10037bafd143Sjb fmovd %f0, %f14 10047bafd143Sjb fmovd %f0, %f16 10057bafd143Sjb fmovd %f0, %f18 10067bafd143Sjb fmovd %f0, %f20 10077bafd143Sjb fmovd %f0, %f22 10087bafd143Sjb fmovd %f0, %f24 10097bafd143Sjb fmovd %f0, %f26 10107bafd143Sjb fmovd %f0, %f28 10117bafd143Sjb fmovd %f0, %f30 10127bafd143Sjb fmovd %f0, %f32 10137bafd143Sjb fmovd %f0, %f34 10147bafd143Sjb fmovd %f0, %f36 10157bafd143Sjb fmovd %f0, %f38 10167bafd143Sjb fmovd %f0, %f40 10177bafd143Sjb fmovd %f0, %f42 10187bafd143Sjb fmovd %f0, %f44 10197bafd143Sjb fmovd %f0, %f46 10207bafd143Sjb fmovd %f0, %f48 10217bafd143Sjb fmovd %f0, %f50 10227bafd143Sjb fmovd %f0, %f52 10237bafd143Sjb fmovd %f0, %f54 10247bafd143Sjb fmovd %f0, %f56 10257bafd143Sjb fmovd %f0, %f58 10267bafd143Sjb fmovd %f0, %f60 10277bafd143Sjb retl 10287bafd143Sjb fmovd %f0, %f62 10297bafd143Sjb SET_SIZE(fp_zero) 10307bafd143Sjb 10312f0fcb93SJason Beloro#endif /* CUSTOM_FPZERO */ 1032