dtrace_subr.c (242723) | dtrace_subr.c (248457) |
---|---|
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 * --- 5 unchanged lines hidden (view full) --- 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 * | 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 * --- 5 unchanged lines hidden (view full) --- 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: head/sys/cddl/dev/dtrace/powerpc/dtrace_subr.c 242723 2012-11-07 23:45:09Z jhibbits $ | 22 * $FreeBSD: head/sys/cddl/dev/dtrace/powerpc/dtrace_subr.c 248457 2013-03-18 05:30:18Z jhibbits $ |
23 * 24 */ 25/* 26 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 27 * Use is subject to license terms. 28 */ 29 30#include <sys/cdefs.h> | 23 * 24 */ 25/* 26 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 27 * Use is subject to license terms. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/cddl/dev/dtrace/powerpc/dtrace_subr.c 242723 2012-11-07 23:45:09Z jhibbits $"); | 31__FBSDID("$FreeBSD: head/sys/cddl/dev/dtrace/powerpc/dtrace_subr.c 248457 2013-03-18 05:30:18Z jhibbits $"); |
32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/types.h> 36#include <sys/kernel.h> 37#include <sys/malloc.h> 38#include <sys/kmem.h> 39#include <sys/smp.h> --- 4 unchanged lines hidden (view full) --- 44#include <machine/trap.h> 45#include <vm/pmap.h> 46 47#define DELAYBRANCH(x) ((int)(x) < 0) 48 49extern uintptr_t dtrace_in_probe_addr; 50extern int dtrace_in_probe; 51extern dtrace_id_t dtrace_probeid_error; | 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/types.h> 36#include <sys/kernel.h> 37#include <sys/malloc.h> 38#include <sys/kmem.h> 39#include <sys/smp.h> --- 4 unchanged lines hidden (view full) --- 44#include <machine/trap.h> 45#include <vm/pmap.h> 46 47#define DELAYBRANCH(x) ((int)(x) < 0) 48 49extern uintptr_t dtrace_in_probe_addr; 50extern int dtrace_in_probe; 51extern dtrace_id_t dtrace_probeid_error; |
52extern int (*dtrace_invop_jump_addr)(struct trapframe *); |
|
52 53int dtrace_invop(uintptr_t, uintptr_t *, uintptr_t); | 53 54int dtrace_invop(uintptr_t, uintptr_t *, uintptr_t); |
55void dtrace_invop_init(void); 56void dtrace_invop_uninit(void); |
|
54 55typedef struct dtrace_invop_hdlr { 56 int (*dtih_func)(uintptr_t, uintptr_t *, uintptr_t); 57 struct dtrace_invop_hdlr *dtih_next; 58} dtrace_invop_hdlr_t; 59 60dtrace_invop_hdlr_t *dtrace_invop_hdlr; 61 --- 5 unchanged lines hidden (view full) --- 67 68 for (hdlr = dtrace_invop_hdlr; hdlr != NULL; hdlr = hdlr->dtih_next) 69 if ((rval = hdlr->dtih_func(addr, stack, eax)) != 0) 70 return (rval); 71 72 return (0); 73} 74 | 57 58typedef struct dtrace_invop_hdlr { 59 int (*dtih_func)(uintptr_t, uintptr_t *, uintptr_t); 60 struct dtrace_invop_hdlr *dtih_next; 61} dtrace_invop_hdlr_t; 62 63dtrace_invop_hdlr_t *dtrace_invop_hdlr; 64 --- 5 unchanged lines hidden (view full) --- 70 71 for (hdlr = dtrace_invop_hdlr; hdlr != NULL; hdlr = hdlr->dtih_next) 72 if ((rval = hdlr->dtih_func(addr, stack, eax)) != 0) 73 return (rval); 74 75 return (0); 76} 77 |
78void 79dtrace_invop_add(int (*func)(uintptr_t, uintptr_t *, uintptr_t)) 80{ 81 dtrace_invop_hdlr_t *hdlr; |
|
75 | 82 |
83 hdlr = kmem_alloc(sizeof (dtrace_invop_hdlr_t), KM_SLEEP); 84 hdlr->dtih_func = func; 85 hdlr->dtih_next = dtrace_invop_hdlr; 86 dtrace_invop_hdlr = hdlr; 87} 88 89void 90dtrace_invop_remove(int (*func)(uintptr_t, uintptr_t *, uintptr_t)) 91{ 92 dtrace_invop_hdlr_t *hdlr = dtrace_invop_hdlr, *prev = NULL; 93 94 for (;;) { 95 if (hdlr == NULL) 96 panic("attempt to remove non-existent invop handler"); 97 98 if (hdlr->dtih_func == func) 99 break; 100 101 prev = hdlr; 102 hdlr = hdlr->dtih_next; 103 } 104 105 if (prev == NULL) { 106 ASSERT(dtrace_invop_hdlr == hdlr); 107 dtrace_invop_hdlr = hdlr->dtih_next; 108 } else { 109 ASSERT(dtrace_invop_hdlr != hdlr); 110 prev->dtih_next = hdlr->dtih_next; 111 } 112 113 kmem_free(hdlr, 0); 114} 115 116 |
|
76/*ARGSUSED*/ 77void 78dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit)) 79{ 80 /* 81 * No toxic regions? 82 */ 83} --- 110 unchanged lines hidden (view full) --- 194dtrace_probe_error(dtrace_state_t *state, dtrace_epid_t epid, int which, 195 int fault, int fltoffs, uintptr_t illval) 196{ 197 198 dtrace_probe(dtrace_probeid_error, (uint64_t)(uintptr_t)state, 199 (uintptr_t)epid, 200 (uintptr_t)which, (uintptr_t)fault, (uintptr_t)fltoffs); 201} | 117/*ARGSUSED*/ 118void 119dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit)) 120{ 121 /* 122 * No toxic regions? 123 */ 124} --- 110 unchanged lines hidden (view full) --- 235dtrace_probe_error(dtrace_state_t *state, dtrace_epid_t epid, int which, 236 int fault, int fltoffs, uintptr_t illval) 237{ 238 239 dtrace_probe(dtrace_probeid_error, (uint64_t)(uintptr_t)state, 240 (uintptr_t)epid, 241 (uintptr_t)which, (uintptr_t)fault, (uintptr_t)fltoffs); 242} |
243 244static int 245dtrace_invop_start(struct trapframe *frame) 246{ 247 switch (dtrace_invop(frame->srr0, (uintptr_t *)frame, frame->fixreg[3])) { 248 case DTRACE_INVOP_JUMP: 249 break; 250 case DTRACE_INVOP_BCTR: 251 frame->srr0 = frame->ctr; 252 break; 253 case DTRACE_INVOP_BLR: 254 frame->srr0 = frame->lr; 255 break; 256 case DTRACE_INVOP_MFLR_R0: 257 frame->fixreg[0] = frame->lr ; 258 break; 259 default: 260 return (-1); 261 break; 262 } 263 264 return (0); 265} 266 267void dtrace_invop_init(void) 268{ 269 dtrace_invop_jump_addr = dtrace_invop_start; 270} 271 272void dtrace_invop_uninit(void) 273{ 274 dtrace_invop_jump_addr = 0; 275} |
|