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/* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27#define _ASM 28#define _LOCORE 29 30#include <sys/cpuvar_defs.h> 31#include <sys/dtrace.h> 32#include <sys/elf_common.h> 33 34#include <machine/armreg.h> 35#include <machine/asm.h> 36 37#include "assym.inc" 38 39/* 40void dtrace_membar_producer(void) 41*/ 42ENTRY(dtrace_membar_producer) 43 RET 44END(dtrace_membar_producer) 45 46/* 47void dtrace_membar_consumer(void) 48*/ 49ENTRY(dtrace_membar_consumer) 50 RET 51END(dtrace_membar_consumer) 52 53/* 54dtrace_icookie_t dtrace_interrupt_disable(void) 55*/ 56ENTRY(dtrace_interrupt_disable) 57 mrs x0, daif 58 msr daifset, #2 59 RET 60END(dtrace_interrupt_disable) 61 62/* 63void dtrace_interrupt_enable(dtrace_icookie_t cookie) 64*/ 65ENTRY(dtrace_interrupt_enable) 66 msr daif, x0 67 RET 68END(dtrace_interrupt_enable) 69/* 70uint8_t 71dtrace_fuword8_nocheck(void *addr) 72*/ 73ENTRY(dtrace_fuword8_nocheck) 74 ldtrb w0, [x0] 75 RET 76END(dtrace_fuword8_nocheck) 77 78/* 79uint16_t 80dtrace_fuword16_nocheck(void *addr) 81*/ 82ENTRY(dtrace_fuword16_nocheck) 83 ldtrh w0, [x0] 84 RET 85END(dtrace_fuword16_nocheck) 86 87/* 88uint32_t 89dtrace_fuword32_nocheck(void *addr) 90*/ 91ENTRY(dtrace_fuword32_nocheck) 92 ldtr w0, [x0] 93 RET 94END(dtrace_fuword32_nocheck) 95 96/* 97uint64_t 98dtrace_fuword64_nocheck(void *addr) 99*/ 100ENTRY(dtrace_fuword64_nocheck) 101 ldtr x0, [x0] 102 RET 103END(dtrace_fuword64_nocheck) 104 105/* 106void 107dtrace_copy(uintptr_t uaddr, uintptr_t kaddr, size_t size) 108*/ 109ENTRY(dtrace_copy) 110 cbz x2, 2f /* If len == 0 then skip loop */ 1111: 112 mvn x4, xzr /* Set all bits */ 113 ldtrb w4, [x0] /* Load from uaddr or raise data abort */ 114 add x0, x0, #1 115 lsr x3, x4, #32 /* Extract zero-extended high bits */ 116 cbnz x3, 2f /* If high bits != 0 then break */ 117 strb w4, [x1], #1 /* Store in kaddr */ 118 sub x2, x2, #1 /* len-- */ 119 cbnz x2, 1b 1202: 121 RET 122END(dtrace_copy) 123 124/* 125void 126dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size) 127*/ 128ENTRY(dtrace_copystr) 129 cbz x2, 2f /* If len == 0 then skip loop */ 1301: 131 mvn x4, xzr /* Set all bits */ 132 ldtrb w4, [x0] /* Load from uaddr or raise data abort */ 133 add x0, x0, #1 134 lsr x3, x4, #32 /* Extract zero-extended high bits */ 135 cbnz x3, 2f /* If high bits != 0 then break */ 136 strb w4, [x1], #1 /* Store in kaddr */ 137 cbz w4, 2f /* If == 0 then break */ 138 sub x2, x2, #1 /* len-- */ 139 cbnz x2, 1b 1402: 141 RET 142END(dtrace_copystr) 143 144/* 145uintptr_t 146dtrace_caller(int aframes) 147*/ 148ENTRY(dtrace_caller) 149 mov x0, #-1 150 RET 151END(dtrace_caller) 152 153/* 154uint32_t 155dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new) 156*/ 157ENTRY(dtrace_cas32) 1581: ldxr w3, [x0] /* Load target */ 159 cmp w3, w1 /* Check if *target == cmp */ 160 bne 2f /* No, return */ 161 stxr w12, w2, [x0] /* Store new to target */ 162 cbnz w12, 1b /* Try again if store not succeed */ 1632: mov w0, w3 /* Return the value loaded from target */ 164 RET 165END(dtrace_cas32) 166 167/* 168void * 169dtrace_casptr(volatile void *target, volatile void *cmp, volatile void *new) 170*/ 171ENTRY(dtrace_casptr) 1721: ldxr x3, [x0] /* Load target */ 173 cmp x3, x1 /* Check if *target == cmp */ 174 bne 2f /* No, return */ 175 stxr w12, x2, [x0] /* Store new to target */ 176 cbnz w12, 1b /* Try again if store not succeed */ 1772: mov x0, x3 /* Return the value loaded from target */ 178 RET 179END(dtrace_casptr) 180 181GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL) 182