Path: blob/main/sys/cddl/dev/dtrace/powerpc/dtrace_asm.S
48375 views
/*1* CDDL HEADER START2*3* The contents of this file are subject to the terms of the4* Common Development and Distribution License, Version 1.0 only5* (the "License"). You may not use this file except in compliance6* with the License.7*8* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE9* or http://www.opensolaris.org/os/licensing.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*21* Portions Copyright 2012,2013 Justin Hibbits <[email protected]>22*/23/*24* Copyright 2004 Sun Microsystems, Inc. All rights reserved.25* Use is subject to license terms.26*/2728#include "assym.inc"2930#define _ASM3132#include <sys/cpuvar_defs.h>33#include <sys/dtrace.h>3435#include <machine/asm.h>36/*37#include <machine/cpu.h>38*/3940/*41* Primitives42*/4344.text4546/*47void dtrace_membar_producer(void)48*/49ASENTRY_NOPROF(dtrace_membar_producer)50sync51blr52END(dtrace_membar_producer)5354/*55void dtrace_membar_consumer(void)56*/57ASENTRY_NOPROF(dtrace_membar_consumer)58isync59blr60END(dtrace_membar_consumer)6162/*63dtrace_icookie_t dtrace_interrupt_disable(void)64*/65ASENTRY_NOPROF(dtrace_interrupt_disable)66mfmsr %r367#ifdef __powerpc64__68/* Two-instruction sequence to clear EE flag */69rldicl %r0,%r3,48,170rotldi %r0,%r0,1671#else72rlwinm %r0,%r3,0,17,15 /* Clear EE flag */73#endif74mtmsr %r075blr76END(dtrace_interrupt_disable)7778/*79void dtrace_interrupt_enable(dtrace_icookie_t cookie)80*/81ASENTRY_NOPROF(dtrace_interrupt_enable)82mtmsr %r383blr84END(dtrace_interrupt_enable)8586/*87uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)88*/89ASENTRY_NOPROF(dtrace_cas32)901:91lwarx %r0,0,%r392cmpw %r4,%r093bne 2f94stwcx. %r5,0,%r395bne 1b962: mr %r3,%r097blr98END(dtrace_cas32)99100/*101void *102dtrace_casptr(void *target, void *cmp, void *new)103*/104ASENTRY_NOPROF(dtrace_casptr)105#ifdef __powerpc64__1061:107ldarx %r0,0,%r3108cmpd %r4,%r0109bne 2f110stdcx. %r5,0,%r3111bne 1b112#else1131:114lwarx %r0,0,%r3115cmpw %r4,%r0116bne 2f117stwcx. %r5,0,%r3118bne 1b119#endif1202: mr %r3,%r0121blr122END(dtrace_casptr)123124125/*126XXX: unoptimized127void128dtrace_copy(uintptr_t src, uintptr_t dest, size_t size)129*/130ASENTRY_NOPROF(dtrace_copy)131subi %r7,%r3,1132subi %r8,%r4,1133mtctr %r51341:135lbzu %r3,1(%r7)136stbu %r3,1(%r8)137bdnz 1b1382:139blr140END(dtrace_copy)141142/*143void144dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,145volatile uint16_t *flags)146*/147ASENTRY_NOPROF(dtrace_copystr)148subi %r7,%r3,1149subi %r8,%r4,11501:151lbzu %r3,1(%r7)152stbu %r3,1(%r8)153subi %r5,%r5,1154#ifdef __powerpc64__155cmpldi %r5,0156#else157cmplwi %r5,0158#endif159beq 2f160cmplwi %r3,0161beq 2f162andi. %r0,%r5,0x0fff163beq 2f164lwz %r0,0(%r6)165andi. %r0,%r0,CPU_DTRACE_BADADDR166beq 1b1672:168blr169END(dtrace_copystr)170171/*172uintptr_t173dtrace_caller(int aframes)174*/175ASENTRY_NOPROF(dtrace_caller)176li %r3, -1177blr178END(dtrace_caller)179180/*181greg_t182dtrace_getfp(void)183*/184ASENTRY_NOPROF(dtrace_getfp)185mr %r3,%r31186blr187END(dtrace_getfp)188189190191