Path: blob/main/sys/cddl/dev/dtrace/aarch64/dtrace_asm.S
48378 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/*22* Copyright 2004 Sun Microsystems, Inc. All rights reserved.23* Use is subject to license terms.24*/2526#define _ASM27#define _LOCORE2829#include <sys/cpuvar_defs.h>30#include <sys/dtrace.h>31#include <sys/elf_common.h>3233#include <machine/armreg.h>34#include <machine/asm.h>3536#include "assym.inc"3738/*39void dtrace_membar_producer(void)40*/41ENTRY(dtrace_membar_producer)42RET43END(dtrace_membar_producer)4445/*46void dtrace_membar_consumer(void)47*/48ENTRY(dtrace_membar_consumer)49RET50END(dtrace_membar_consumer)5152/*53dtrace_icookie_t dtrace_interrupt_disable(void)54*/55ENTRY(dtrace_interrupt_disable)56mrs x0, daif57msr daifset, #258RET59END(dtrace_interrupt_disable)6061/*62void dtrace_interrupt_enable(dtrace_icookie_t cookie)63*/64ENTRY(dtrace_interrupt_enable)65msr daif, x066RET67END(dtrace_interrupt_enable)68/*69uint8_t70dtrace_fuword8_nocheck(void *addr)71*/72ENTRY(dtrace_fuword8_nocheck)73ldtrb w0, [x0]74RET75END(dtrace_fuword8_nocheck)7677/*78uint16_t79dtrace_fuword16_nocheck(void *addr)80*/81ENTRY(dtrace_fuword16_nocheck)82ldtrh w0, [x0]83RET84END(dtrace_fuword16_nocheck)8586/*87uint32_t88dtrace_fuword32_nocheck(void *addr)89*/90ENTRY(dtrace_fuword32_nocheck)91ldtr w0, [x0]92RET93END(dtrace_fuword32_nocheck)9495/*96uint64_t97dtrace_fuword64_nocheck(void *addr)98*/99ENTRY(dtrace_fuword64_nocheck)100ldtr x0, [x0]101RET102END(dtrace_fuword64_nocheck)103104/*105void106dtrace_copy(uintptr_t uaddr, uintptr_t kaddr, size_t size)107*/108ENTRY(dtrace_copy)109cbz x2, 2f /* If len == 0 then skip loop */1101:111ldtrb w4, [x0] /* Load from uaddr */112add x0, x0, #1113strb w4, [x1], #1 /* Store in kaddr */114sub x2, x2, #1 /* len-- */115cbnz x2, 1b1162:117RET118END(dtrace_copy)119120/*121void122dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,123volatile uint16_t *flags)124XXX: Check for flags?125*/126ENTRY(dtrace_copystr)127cbz x2, 2f /* If len == 0 then skip loop */1281:129ldtrb w4, [x0] /* Load from uaddr */130add x0, x0, #1131strb w4, [x1], #1 /* Store in kaddr */132cbz w4, 2f /* If == 0 then break */133sub x2, x2, #1 /* len-- */134cbnz x2, 1b1352:136RET137END(dtrace_copystr)138139/*140uintptr_t141dtrace_caller(int aframes)142*/143ENTRY(dtrace_caller)144mov x0, #-1145RET146END(dtrace_caller)147148/*149uint32_t150dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)151*/152ENTRY(dtrace_cas32)1531: ldxr w3, [x0] /* Load target */154cmp w3, w1 /* Check if *target == cmp */155bne 2f /* No, return */156stxr w12, w2, [x0] /* Store new to target */157cbnz w12, 1b /* Try again if store not succeed */1582: mov w0, w3 /* Return the value loaded from target */159RET160END(dtrace_cas32)161162/*163void *164dtrace_casptr(volatile void *target, volatile void *cmp, volatile void *new)165*/166ENTRY(dtrace_casptr)1671: ldxr x3, [x0] /* Load target */168cmp x3, x1 /* Check if *target == cmp */169bne 2f /* No, return */170stxr w12, x2, [x0] /* Store new to target */171cbnz w12, 1b /* Try again if store not succeed */1722: mov x0, x3 /* Return the value loaded from target */173RET174END(dtrace_casptr)175176GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)177178179