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 * Portions Copyright 2012,2013 Justin Hibbits <jhibbits@freebsd.org> 23 */ 24/* 25 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms. 27 */ 28 29#include "assym.inc" 30 31#define _ASM 32 33#include <sys/cpuvar_defs.h> 34#include <sys/dtrace.h> 35 36#include <machine/asm.h> 37/* 38#include <machine/cpu.h> 39*/ 40 41/* 42 * Primitives 43 */ 44 45 .text 46 47/* 48void dtrace_membar_producer(void) 49*/ 50ASENTRY_NOPROF(dtrace_membar_producer) 51 sync 52 blr 53END(dtrace_membar_producer) 54 55/* 56void dtrace_membar_consumer(void) 57*/ 58ASENTRY_NOPROF(dtrace_membar_consumer) 59 isync 60 blr 61END(dtrace_membar_consumer) 62 63/* 64dtrace_icookie_t dtrace_interrupt_disable(void) 65*/ 66ASENTRY_NOPROF(dtrace_interrupt_disable) 67 mfmsr %r3 68#ifdef __powerpc64__ 69 /* Two-instruction sequence to clear EE flag */ 70 rldicl %r0,%r3,48,1 71 rotldi %r0,%r0,16 72#else 73 rlwinm %r0,%r3,0,17,15 /* Clear EE flag */ 74#endif 75 mtmsr %r0 76 blr 77END(dtrace_interrupt_disable) 78 79/* 80void dtrace_interrupt_enable(dtrace_icookie_t cookie) 81*/ 82ASENTRY_NOPROF(dtrace_interrupt_enable) 83 mtmsr %r3 84 blr 85END(dtrace_interrupt_enable) 86 87/* 88uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new) 89*/ 90ASENTRY_NOPROF(dtrace_cas32) 911: 92 lwarx %r0,0,%r3 93 cmpw %r4,%r0 94 bne 2f 95 stwcx. %r5,0,%r3 96 bne 1b 972: mr %r3,%r0 98 blr 99END(dtrace_cas32) 100 101/* 102void * 103dtrace_casptr(void *target, void *cmp, void *new) 104*/ 105ASENTRY_NOPROF(dtrace_casptr) 106#ifdef __powerpc64__ 1071: 108 ldarx %r0,0,%r3 109 cmpd %r4,%r0 110 bne 2f 111 stdcx. %r5,0,%r3 112 bne 1b 113#else 1141: 115 lwarx %r0,0,%r3 116 cmpw %r4,%r0 117 bne 2f 118 stwcx. %r5,0,%r3 119 bne 1b 120#endif 1212: mr %r3,%r0 122 blr 123END(dtrace_casptr) 124 125 126/* 127XXX: unoptimized 128void 129dtrace_copy(uintptr_t src, uintptr_t dest, size_t size) 130*/ 131ASENTRY_NOPROF(dtrace_copy) 132 subi %r7,%r3,1 133 subi %r8,%r4,1 134 mtctr %r5 1351: 136 lbzu %r3,1(%r7) 137 stbu %r3,1(%r8) 138 bdnz 1b 1392: 140 blr 141END(dtrace_copy) 142 143/* 144void 145dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size, 146 volatile uint16_t *flags) 147*/ 148ASENTRY_NOPROF(dtrace_copystr) 149 subi %r7,%r3,1 150 subi %r8,%r4,1 1511: 152 lbzu %r3,1(%r7) 153 stbu %r3,1(%r8) 154 subi %r5,%r5,1 155#ifdef __powerpc64__ 156 cmpldi %r5,0 157#else 158 cmplwi %r5,0 159#endif 160 beq 2f 161 cmplwi %r3,0 162 beq 2f 163 andi. %r0,%r5,0x0fff 164 beq 2f 165 lwz %r0,0(%r6) 166 andi. %r0,%r0,CPU_DTRACE_BADADDR 167 beq 1b 1682: 169 blr 170END(dtrace_copystr) 171 172/* 173uintptr_t 174dtrace_caller(int aframes) 175*/ 176ASENTRY_NOPROF(dtrace_caller) 177 li %r3, -1 178 blr 179END(dtrace_caller) 180 181/* 182greg_t 183dtrace_getfp(void) 184*/ 185ASENTRY_NOPROF(dtrace_getfp) 186 mr %r3,%r31 187 blr 188END(dtrace_getfp) 189 190