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 * $FreeBSD$ 25 */ 26/* 27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 28 * Use is subject to license terms. 29 */ 30 31#include "assym.s" 32 33#define _ASM 34 35#include <sys/cpuvar_defs.h> 36#include <sys/dtrace.h> 37 38#include <machine/asm.h> 39/* 40#include <machine/cpu.h> 41*/ 42 43/* 44 * Primitives 45 */ 46 47 .text 48 49/* 50void dtrace_membar_producer(void) 51*/ 52ASENTRY_NOPROF(dtrace_membar_producer) 53 sync 54 blr 55END(dtrace_membar_producer) 56 57/* 58void dtrace_membar_consumer(void) 59*/ 60ASENTRY_NOPROF(dtrace_membar_consumer) 61 isync 62 blr 63END(dtrace_membar_consumer) 64 65/* 66dtrace_icookie_t dtrace_interrupt_disable(void) 67*/ 68ASENTRY_NOPROF(dtrace_interrupt_disable) 69 mfmsr %r3 70 andi. %r0,%r3,~PSL_EE@l 71 mtmsr %r0 72 blr 73END(dtrace_interrupt_disable) 74 75/* 76void dtrace_interrupt_enable(dtrace_icookie_t cookie) 77*/ 78ASENTRY_NOPROF(dtrace_interrupt_enable) 79 mtmsr %r3 80 blr 81END(dtrace_interrupt_enable) 82 83/* 84uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new) 85*/ 86ASENTRY_NOPROF(dtrace_cas32) 871: 88 lwarx %r0,0,%r3 89 cmpw %r4,%r0 90 bne 2f 91 stwcx. %r5,0,%r3 92 bne 1b 932: mr %r3,%r0 94 blr 95END(dtrace_cas32) 96 97/* 98void * 99dtrace_casptr(void *target, void *cmp, void *new) 100*/ 101ASENTRY_NOPROF(dtrace_casptr) 102#ifdef __powerpc64__ 1031: 104 ldarx %r0,0,%r3 105 cmpd %r4,%r0 106 bne 2f 107 stdcx. %r5,0,%r3 108 bne 1b 109#else 1101: 111 lwarx %r0,0,%r3 112 cmpw %r4,%r0 113 bne 2f 114 stwcx. %r5,0,%r3 115 bne 1b 116#endif 1172: mr %r3,%r0 118 blr 119END(dtrace_casptr) 120 121 122/* 123XXX: unoptimized 124void 125dtrace_copy(uintptr_t src, uintptr_t dest, size_t size) 126*/ 127ASENTRY_NOPROF(dtrace_copy) 128 subi %r7,%r3,1 129 subi %r8,%r4,1 130 mtctr %r5 1311: 132 lbzu %r3,1(%r7) 133 stbu %r3,1(%r8) 134 bdnz 1b 1352: 136 blr 137END(dtrace_copy) 138 139/* 140void 141dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size, 142 volatile uint16_t *flags) 143*/ 144ASENTRY_NOPROF(dtrace_copystr) 145 addme %r7,%r3 146 addme %r8,%r4 1471: 148 lbzu %r3,1(%r7) 149 stbu %r3,1(%r8) 150 addme %r5,%r5 151 beq 2f 152 or %r3,%r3,%r3 153 beq 2f 154 andi. %r0,%r5,0x0fff 155 beq 2f 156 lwz %r0,0(%r6) 157 andi. %r0,%r0,CPU_DTRACE_BADADDR 158 beq 1b 1592: 160 blr 161END(dtrace_copystr) 162 163/* 164 * The panic() and cmn_err() functions invoke vpanic() as a common entry point 165 * into the panic code implemented in panicsys(). vpanic() is responsible 166 * for passing through the format string and arguments, and constructing a 167 * regs structure on the stack into which it saves the current register 168 * values. If we are not dying due to a fatal trap, these registers will 169 * then be preserved in panicbuf as the current processor state. Before 170 * invoking panicsys(), vpanic() activates the first panic trigger (see 171 * common/os/panic.c) and switches to the panic_stack if successful. Note that 172 * DTrace takes a slightly different panic path if it must panic from probe 173 * context. Instead of calling panic, it calls into dtrace_vpanic(), which 174 * sets up the initial stack as vpanic does, calls dtrace_panic_trigger(), and 175 * branches back into vpanic(). 176 */ 177 178/* 179void 180vpanic(const char *format, va_list alist) 181*/ 182ASENTRY_NOPROF(vpanic) /* Initial stack layout: */ 183 184vpanic_common: 185 blr 186END(vpanic) 187 188 189 190/* 191void 192dtrace_vpanic(const char *format, va_list alist) 193*/ 194ASENTRY_NOPROF(dtrace_vpanic) /* Initial stack layout: */ 195 196#if 0 197 bl dtrace_panic_trigger /* %eax = dtrace_panic_trigger() */ 198#endif 199 b vpanic_common 200END(dtrace_vpanic) 201 202/* 203uintptr_t 204dtrace_caller(int aframes) 205*/ 206ASENTRY_NOPROF(dtrace_caller) 207 li %r3, -1 208 blr 209END(dtrace_caller) 210 211