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/armreg.h> 36#include <machine/asm.h> 37 38#include "assym.s" 39 40/* 41void dtrace_membar_producer(void) 42*/ 43ENTRY(dtrace_membar_producer) 44 RET 45END(dtrace_membar_producer) 46 47/* 48void dtrace_membar_consumer(void) 49*/ 50ENTRY(dtrace_membar_consumer) 51 RET 52END(dtrace_membar_consumer) 53 54/* 55dtrace_icookie_t dtrace_interrupt_disable(void) 56*/ 57ENTRY(dtrace_interrupt_disable) 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 daifclr, #2 67 RET 68END(dtrace_interrupt_enable) 69/* 70uint8_t 71dtrace_fuword8_nocheck(void *addr) 72*/ 73ENTRY(dtrace_fuword8_nocheck) 74 ldrb w0, [x0] 75 RET 76END(dtrace_fuword8_nocheck) 77 78/* 79uint16_t 80dtrace_fuword16_nocheck(void *addr) 81*/ 82ENTRY(dtrace_fuword16_nocheck) 83 ldrh w0, [x0] 84 RET 85END(dtrace_fuword16_nocheck) 86 87/* 88uint32_t 89dtrace_fuword32_nocheck(void *addr) 90*/ 91ENTRY(dtrace_fuword32_nocheck) 92 ldr w0, [x0] 93 RET 94END(dtrace_fuword32_nocheck) 95 96/* 97uint64_t 98dtrace_fuword64_nocheck(void *addr) 99*/ 100ENTRY(dtrace_fuword64_nocheck) 101 ldr 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 ldrb w4, [x0], #1 /* Load from uaddr */ 113 strb w4, [x1], #1 /* Store in kaddr */ 114 sub x2, x2, #1 /* len-- */ 115 cbnz x2, 1b 1162: 117 RET 118END(dtrace_copy) 119 120/* 121void 122dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size, 123 volatile uint16_t *flags) 124XXX: Check for flags? 125*/ 126ENTRY(dtrace_copystr) 127 cbz x2, 2f /* If len == 0 then skip loop */ 128 1291: ldrb w4, [x0], #1 /* Load from uaddr */ 130 strb w4, [x1], #1 /* Store in kaddr */ 131 cbz w4, 2f /* If == 0 then break */ 132 sub x2, x2, #1 /* len-- */ 133 cbnz x2, 1b 1342: 135 RET 136END(dtrace_copystr) 137 138/* 139uintptr_t 140dtrace_caller(int aframes) 141*/ 142ENTRY(dtrace_caller) 143 mov x0, #-1 144 RET 145END(dtrace_caller) 146 147/* 148uint32_t 149dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new) 150*/ 151ENTRY(dtrace_cas32) 1521: ldxr w3, [x0] /* Load target */ 153 cmp w3, w1 /* Check if *target == cmp */ 154 bne 2f /* No, return */ 155 stxr w12, w2, [x0] /* Store new to target */ 156 cbnz w12, 1b /* Try again if store not succeed */ 1572: mov w0, w3 /* Return the value loaded from target */ 158 RET 159END(dtrace_cas32) 160 161/* 162void * 163dtrace_casptr(volatile void *target, volatile void *cmp, volatile void *new) 164*/ 165ENTRY(dtrace_casptr) 1661: ldxr x3, [x0] /* Load target */ 167 cmp x3, x1 /* Check if *target == cmp */ 168 bne 2f /* No, return */ 169 stxr w12, x2, [x0] /* Store new to target */ 170 cbnz w12, 1b /* Try again if store not succeed */ 1712: mov x0, x3 /* Return the value loaded from target */ 172 RET 173END(dtrace_casptr) 174