Home | History | Annotate | Line # | Download | only in mips
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License, Version 1.0 only
      6  * (the "License").  You may not use this file except in compliance
      7  * with the License.
      8  *
      9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  * or http://www.opensolaris.org/os/licensing.
     11  * See the License for the specific language governing permissions
     12  * and limitations under the License.
     13  *
     14  * When distributing Covered Code, include this CDDL HEADER in each
     15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  * If applicable, add the following below this CDDL HEADER, with the
     17  * fields enclosed by brackets "[]" replaced with your own identifying
     18  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  *
     20  * CDDL HEADER END
     21  *
     22  * $FreeBSD$
     23  */
     24 /*
     25  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
     26  * Use is subject to license terms.
     27  */
     28 
     29 #define _ASM
     30 #define _LOCORE
     31 
     32 #include <sys/cpuvar_defs.h>
     33 #include <sys/dtrace.h>
     34 
     35 #include <machine/asm.h>
     36 #include <mips/cpuregs.h>
     37 #include <machine/regnum.h>
     38 
     39         .set    noreorder               # Noreorder is default style!
     40 
     41 /*
     42  * Primitives
     43  */
     44 
     45         .text
     46 
     47 /*
     48 void dtrace_membar_producer(void)
     49 */
     50 LEAF(dtrace_membar_producer)
     51 	j	ra
     52 	nop
     53 END(dtrace_membar_producer)
     54 
     55 /*
     56 void dtrace_membar_consumer(void)
     57 */
     58 LEAF(dtrace_membar_consumer)
     59 	j	ra
     60 	nop
     61 END(dtrace_membar_consumer)
     62 
     63 /*
     64 dtrace_icookie_t dtrace_interrupt_disable(void)
     65 */
     66 LEAF(dtrace_interrupt_disable)
     67 	mfc0	t0, MIPS_COP_0_STATUS
     68 	move	v0, t0
     69 	and	v0, v0, MIPS_SR_INT_IE
     70 	and	t0, t0, ~MIPS_SR_INT_IE
     71 	mtc0	t0, MIPS_COP_0_STATUS
     72 	j	ra
     73 	nop
     74 END(dtrace_interrupt_disable)
     75 
     76 /*
     77 void dtrace_interrupt_enable(dtrace_icookie_t cookie)
     78 */
     79 LEAF(dtrace_interrupt_enable)
     80 	mfc0	t0, MIPS_COP_0_STATUS
     81 	beqz	a0, not_enabled
     82 	or	t0, t0, MIPS_SR_INT_IE
     83 	mtc0	t0, MIPS_COP_0_STATUS
     84 not_enabled:
     85 	j	ra
     86 	nop
     87 END(dtrace_interrupt_enable)
     88 
     89 /*
     90 uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
     91 */
     92 LEAF(dtrace_cas32)
     93 1:
     94 	move	t1, a2
     95 	ll	t0, 0(a0)
     96 	bne	t0, a1, 2f
     97 	nop
     98 	sc	t1, 0(a0)
     99 	beqz	t1, 1b
    100 	nop
    101 2:	move	v0, t0
    102 	j	ra
    103 	nop
    104 END(dtrace_cas32)
    105 
    106 /*
    107 void *
    108 dtrace_casptr(void *target, void *cmp, void *new)
    109 */
    110 LEAF(dtrace_casptr)
    111 1:
    112 	move	t1, a2
    113 	PTR_LL	t0, 0(a0)
    114 	bne	t0, a1, 2f
    115 	nop
    116 	PTR_SC	t1, 0(a0)
    117 	beqz	t1, 1b
    118 	nop
    119 2:	move	v0, t0
    120 	j	ra
    121 	nop
    122 END(dtrace_casptr)
    123 
    124 
    125 /*
    126 uintptr_t
    127 dtrace_fulword(void *addr)
    128 */
    129 LEAF(dtrace_fulword)
    130 END(dtrace_fulword)
    131 
    132 /*
    133 uint8_t
    134 dtrace_fuword8_nocheck(void *addr)
    135 */
    136 LEAF(dtrace_fuword8_nocheck)
    137 	lbu	v0, 0(a0)
    138 	j	ra
    139 	nop
    140 END(dtrace_fuword8_nocheck)
    141 
    142 /*
    143 uint16_t
    144 dtrace_fuword16_nocheck(void *addr)
    145 */
    146 LEAF(dtrace_fuword16_nocheck)
    147 	lhu	v0, 0(a0)
    148 	j	ra
    149 	nop
    150 END(dtrace_fuword16_nocheck)
    151 
    152 /*
    153 uint32_t
    154 dtrace_fuword32_nocheck(void *addr)
    155 */
    156 LEAF(dtrace_fuword32_nocheck)
    157 	lw	v0, 0(a0)
    158 	j	ra
    159 	nop
    160 END(dtrace_fuword32_nocheck)
    161 
    162 /*
    163 uint64_t
    164 dtrace_fuword64_nocheck(void *addr)
    165 */
    166 LEAF(dtrace_fuword64_nocheck)
    167 #if defined(__mips_n64) || defined(__mips_n32)
    168 	ld	v0, 0(a0)
    169 #else
    170 	lw	v1,4(a0)
    171 	lw	v0,0(a0)
    172 #endif
    173 	j	ra
    174 	nop
    175 END(dtrace_fuword64_nocheck)
    176 
    177 /*
    178 XXX: unoptimized
    179 void
    180 dtrace_copy(uintptr_t src, uintptr_t dest, size_t size)
    181 */
    182 LEAF(dtrace_copy)
    183 1:
    184 	beqz	a2, 2f
    185 	nop
    186 	lbu	t0, 0(a0)
    187 	sb	t0, 0(a1)
    188 	PTR_ADDU	a0, a0, 1
    189 	PTR_ADDU	a1, a1, 1
    190 	INT_SUBU	a2, a2, 1
    191 	j	1b
    192 	nop
    193 2:
    194 	j	ra
    195 	nop
    196 END(dtrace_copy)
    197 
    198 /*
    199 XXX: Unoptimized. Check for flags on page boundaries only(?)
    200 void
    201 dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
    202     volatile uint16_t *flags)
    203 */
    204 LEAF(dtrace_copystr)
    205 1:
    206 	lbu	t0, 0(a0)
    207 	sb	t0, 0(a1)
    208 	PTR_ADDU	a0, a0, 1
    209 	PTR_ADDU	a1, a1, 1
    210 	INT_SUBU	a2, a2, 1
    211 	beqz	t0, 2f
    212 	nop
    213 	lhu	t1, (a3)
    214 	and	t1, t1, CPU_DTRACE_BADADDR
    215 	bnez	t1, 2f
    216 	nop
    217 
    218 	bnez	a2, 1b
    219 	nop
    220 2:
    221 	j	ra
    222 	nop
    223 END(dtrace_copystr)
    224 
    225 /*
    226 uintptr_t
    227 dtrace_caller(int aframes)
    228 */
    229 LEAF(dtrace_caller)
    230 	li	v0, -1
    231 	j	ra
    232 	nop
    233 END(dtrace_caller)
    234