Make dtrace/zfs compile on arm based on the diff from:
http://people.freebsd.org/~gonzo/arm/dtrace-arm.diff Completely untested, kernel support not added.
This commit is contained in:
parent
7733018eca
commit
22898e3a43
222
external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S
vendored
Normal file
222
external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S
vendored
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
/*
|
||||||
|
* CDDL HEADER START
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the terms of the
|
||||||
|
* Common Development and Distribution License, Version 1.0 only
|
||||||
|
* (the "License"). You may not use this file except in compliance
|
||||||
|
* with the License.
|
||||||
|
*
|
||||||
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||||
|
* or http://www.opensolaris.org/os/licensing.
|
||||||
|
* See the License for the specific language governing permissions
|
||||||
|
* and limitations under the License.
|
||||||
|
*
|
||||||
|
* When distributing Covered Code, include this CDDL HEADER in each
|
||||||
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||||
|
* If applicable, add the following below this CDDL HEADER, with the
|
||||||
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
||||||
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
||||||
|
*
|
||||||
|
* CDDL HEADER END
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _ASM
|
||||||
|
#define _LOCORE
|
||||||
|
#define LOCORE
|
||||||
|
|
||||||
|
#include <sys/cpuvar_defs.h>
|
||||||
|
#include <sys/dtrace.h>
|
||||||
|
|
||||||
|
#include <machine/asm.h>
|
||||||
|
|
||||||
|
#include "assym.s"
|
||||||
|
|
||||||
|
/*
|
||||||
|
void dtrace_membar_producer(void)
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_membar_producer)
|
||||||
|
RET
|
||||||
|
|
||||||
|
/*
|
||||||
|
void dtrace_membar_consumer(void)
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_membar_consumer)
|
||||||
|
RET
|
||||||
|
|
||||||
|
/*
|
||||||
|
dtrace_icookie_t dtrace_interrupt_disable(void)
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_interrupt_disable)
|
||||||
|
mrs r0, cpsr
|
||||||
|
mov r1, r0
|
||||||
|
orr r1, r1, #(I32_bit|F32_bit)
|
||||||
|
msr cpsr_c, r1
|
||||||
|
RET
|
||||||
|
/*
|
||||||
|
void dtrace_interrupt_enable(dtrace_icookie_t cookie)
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_interrupt_enable)
|
||||||
|
and r0, r0, #(I32_bit|F32_bit)
|
||||||
|
mrs r1, cpsr
|
||||||
|
bic r1, r1, #(I32_bit|F32_bit)
|
||||||
|
orr r1, r1, r0
|
||||||
|
msr cpsr_c, r1
|
||||||
|
RET
|
||||||
|
|
||||||
|
/*
|
||||||
|
uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
|
||||||
|
XXX: just disable interrupts for now, add proper implementation for
|
||||||
|
ARMv6/ARMv7 later
|
||||||
|
*/
|
||||||
|
ENTRY_NP(dtrace_casptr)
|
||||||
|
ENTRY(dtrace_cas32)
|
||||||
|
stmfd sp!, {r4, r5}
|
||||||
|
|
||||||
|
mrs r3, cpsr
|
||||||
|
mov r4, r3
|
||||||
|
orr r4, r4, #(I32_bit|F32_bit)
|
||||||
|
msr cpsr_c, r4
|
||||||
|
|
||||||
|
ldr r5, [r0]
|
||||||
|
cmp r5, r2
|
||||||
|
movne r0, #0
|
||||||
|
bne 2f
|
||||||
|
|
||||||
|
str r2, [r0]
|
||||||
|
mov r0, #1
|
||||||
|
|
||||||
|
2:
|
||||||
|
msr cpsr_c, r3
|
||||||
|
ldmfd sp!, {r4, r5}
|
||||||
|
RET
|
||||||
|
|
||||||
|
/*
|
||||||
|
uint8_t
|
||||||
|
dtrace_fuword8_nocheck(void *addr)
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_fuword8_nocheck)
|
||||||
|
ldrb r3, [r0]
|
||||||
|
mov r0, r3
|
||||||
|
RET
|
||||||
|
|
||||||
|
/*
|
||||||
|
uint16_t
|
||||||
|
dtrace_fuword16_nocheck(void *addr)
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_fuword16_nocheck)
|
||||||
|
ldrh r3, [r0]
|
||||||
|
mov r0, r3
|
||||||
|
RET
|
||||||
|
|
||||||
|
/*
|
||||||
|
uint32_t
|
||||||
|
dtrace_fuword32_nocheck(void *addr)
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_fuword32_nocheck)
|
||||||
|
ldr r3, [r0]
|
||||||
|
mov r0, r3
|
||||||
|
RET
|
||||||
|
|
||||||
|
/*
|
||||||
|
uint64_t
|
||||||
|
dtrace_fuword64_nocheck(void *addr)
|
||||||
|
XXX: add byteorder check
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_fuword64_nocheck)
|
||||||
|
ldm r0, {r2, r3}
|
||||||
|
|
||||||
|
mov r0, r2
|
||||||
|
mov r1, r3
|
||||||
|
#if 0
|
||||||
|
/* little endian */
|
||||||
|
mov r0, r2
|
||||||
|
mov r1, r3
|
||||||
|
/* big endian */
|
||||||
|
mov r0, r3
|
||||||
|
mov r1, r2
|
||||||
|
#endif
|
||||||
|
RET
|
||||||
|
|
||||||
|
/*
|
||||||
|
void
|
||||||
|
dtrace_copy(uintptr_t uaddr, uintptr_t kaddr, size_t size)
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_copy)
|
||||||
|
stmfd sp!, {r4-r5} /* stack is 8 byte aligned */
|
||||||
|
teq r2, #0x00000000
|
||||||
|
mov r5, #0x00000000
|
||||||
|
beq 2f
|
||||||
|
|
||||||
|
1: ldrb r4, [r0], #0x0001
|
||||||
|
add r5, r5, #0x00000001
|
||||||
|
strb r4, [r1], #0x0001
|
||||||
|
teqne r5, r2
|
||||||
|
bne 1b
|
||||||
|
|
||||||
|
2: ldmfd sp!, {r4-r5} /* stack is 8 byte aligned */
|
||||||
|
RET
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
void
|
||||||
|
dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
|
||||||
|
volatile uint16_t *flags)
|
||||||
|
XXX: Check for flags?
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_copystr)
|
||||||
|
stmfd sp!, {r4-r5} /* stack is 8 byte aligned */
|
||||||
|
teq r2, #0x00000000
|
||||||
|
mov r5, #0x00000000
|
||||||
|
beq 2f
|
||||||
|
|
||||||
|
1: ldrb r4, [r0], #0x0001
|
||||||
|
add r5, r5, #0x00000001
|
||||||
|
teq r4, #0x00000000
|
||||||
|
strb r4, [r1], #0x0001
|
||||||
|
teqne r5, r2
|
||||||
|
bne 1b
|
||||||
|
|
||||||
|
2: ldmfd sp!, {r4-r5} /* stack is 8 byte aligned */
|
||||||
|
RET
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
void dtrace_invop_init(void)
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_invop_init)
|
||||||
|
RET
|
||||||
|
|
||||||
|
/*
|
||||||
|
void dtrace_invop_uninit(void)
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_invop_uninit)
|
||||||
|
RET
|
||||||
|
|
||||||
|
/*
|
||||||
|
void
|
||||||
|
vpanic(const char *format, va_list alist)
|
||||||
|
*/
|
||||||
|
ENTRY(vpanic) /* Initial stack layout: */
|
||||||
|
vpanic_common:
|
||||||
|
RET
|
||||||
|
|
||||||
|
/*
|
||||||
|
void
|
||||||
|
dtrace_vpanic(const char *format, va_list alist)
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_vpanic) /* Initial stack layout: */
|
||||||
|
RET
|
||||||
|
|
||||||
|
/*
|
||||||
|
uintptr_t
|
||||||
|
dtrace_caller(int aframes)
|
||||||
|
*/
|
||||||
|
ENTRY(dtrace_caller)
|
||||||
|
mov r0, #-1
|
||||||
|
RET
|
325
external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c
vendored
Normal file
325
external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c
vendored
Normal file
@ -0,0 +1,325 @@
|
|||||||
|
/*
|
||||||
|
* CDDL HEADER START
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the terms of the
|
||||||
|
* Common Development and Distribution License, Version 1.0 only
|
||||||
|
* (the "License"). You may not use this file except in compliance
|
||||||
|
* with the License.
|
||||||
|
*
|
||||||
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||||
|
* or http://www.opensolaris.org/os/licensing.
|
||||||
|
* See the License for the specific language governing permissions
|
||||||
|
* and limitations under the License.
|
||||||
|
*
|
||||||
|
* When distributing Covered Code, include this CDDL HEADER in each
|
||||||
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||||
|
* If applicable, add the following below this CDDL HEADER, with the
|
||||||
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
||||||
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
||||||
|
*
|
||||||
|
* CDDL HEADER END
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
*/
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/stack.h>
|
||||||
|
#include <sys/pcpu.h>
|
||||||
|
|
||||||
|
#include <machine/frame.h>
|
||||||
|
#include <machine/md_var.h>
|
||||||
|
#include <machine/reg.h>
|
||||||
|
|
||||||
|
#include <vm/vm.h>
|
||||||
|
#include <vm/vm_param.h>
|
||||||
|
#include <vm/pmap.h>
|
||||||
|
|
||||||
|
#include <machine/db_machdep.h>
|
||||||
|
#include <machine/md_var.h>
|
||||||
|
#include <machine/vmparam.h>
|
||||||
|
#include <machine/stack.h>
|
||||||
|
#include <ddb/db_sym.h>
|
||||||
|
#include <ddb/ddb.h>
|
||||||
|
#include <sys/kdb.h>
|
||||||
|
|
||||||
|
#include "regset.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wee need some reasonable default to prevent backtrace code
|
||||||
|
* from wandering too far
|
||||||
|
*/
|
||||||
|
#define MAX_FUNCTION_SIZE 0x10000
|
||||||
|
#define MAX_PROLOGUE_SIZE 0x100
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t dtrace_fuword8_nocheck(void *);
|
||||||
|
uint16_t dtrace_fuword16_nocheck(void *);
|
||||||
|
uint32_t dtrace_fuword32_nocheck(void *);
|
||||||
|
uint64_t dtrace_fuword64_nocheck(void *);
|
||||||
|
|
||||||
|
void
|
||||||
|
dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
|
||||||
|
uint32_t *intrpc)
|
||||||
|
{
|
||||||
|
u_int32_t *frame, *lastframe;
|
||||||
|
int scp_offset;
|
||||||
|
int depth = 0;
|
||||||
|
pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller;
|
||||||
|
|
||||||
|
if (intrpc != 0)
|
||||||
|
pcstack[depth++] = (pc_t) intrpc;
|
||||||
|
|
||||||
|
aframes++;
|
||||||
|
|
||||||
|
frame = (u_int32_t *)__builtin_frame_address(0);;
|
||||||
|
lastframe = NULL;
|
||||||
|
scp_offset = -(get_pc_str_offset() >> 2);
|
||||||
|
|
||||||
|
while ((frame != NULL) && (depth < pcstack_limit)) {
|
||||||
|
db_addr_t scp;
|
||||||
|
#if 0
|
||||||
|
u_int32_t savecode;
|
||||||
|
int r;
|
||||||
|
u_int32_t *rp;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In theory, the SCP isn't guaranteed to be in the function
|
||||||
|
* that generated the stack frame. We hope for the best.
|
||||||
|
*/
|
||||||
|
scp = frame[FR_SCP];
|
||||||
|
printf("--> %08x\n", (uint32_t)scp);
|
||||||
|
|
||||||
|
if (aframes > 0) {
|
||||||
|
aframes--;
|
||||||
|
if ((aframes == 0) && (caller != 0)) {
|
||||||
|
pcstack[depth++] = caller;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("++ --> %08x\n", (uint32_t)scp);
|
||||||
|
pcstack[depth++] = scp;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
savecode = ((u_int32_t *)scp)[scp_offset];
|
||||||
|
if ((savecode & 0x0e100000) == 0x08000000) {
|
||||||
|
/* Looks like an STM */
|
||||||
|
rp = frame - 4;
|
||||||
|
for (r = 10; r >= 0; r--) {
|
||||||
|
if (savecode & (1 << r)) {
|
||||||
|
/* register r == *rp-- */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Switch to next frame up
|
||||||
|
*/
|
||||||
|
if (frame[FR_RFP] == 0)
|
||||||
|
break; /* Top of stack */
|
||||||
|
|
||||||
|
lastframe = frame;
|
||||||
|
frame = (u_int32_t *)(frame[FR_RFP]);
|
||||||
|
|
||||||
|
if (INKERNEL((int)frame)) {
|
||||||
|
/* staying in kernel */
|
||||||
|
if (frame <= lastframe) {
|
||||||
|
/* bad frame pointer */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; depth < pcstack_limit; depth++) {
|
||||||
|
pcstack[depth] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dtrace_getupcstack(uint64_t *pcstack, int pcstack_limit)
|
||||||
|
{
|
||||||
|
printf("unimplemented\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
dtrace_getustackdepth(void)
|
||||||
|
{
|
||||||
|
printf("unimplemented\n");
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dtrace_getufpstack(uint64_t *pcstack, uint64_t *fpstack, int pcstack_limit)
|
||||||
|
{
|
||||||
|
printf("IMPLEMENT ME: %s\n", __func__);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*ARGSUSED*/
|
||||||
|
uint64_t
|
||||||
|
dtrace_getarg(int arg, int aframes)
|
||||||
|
{
|
||||||
|
printf("unimplemented\n");
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
dtrace_getstackdepth(int aframes)
|
||||||
|
{
|
||||||
|
u_int32_t *frame, *lastframe;
|
||||||
|
int scp_offset;
|
||||||
|
int depth = 1;
|
||||||
|
|
||||||
|
frame = (u_int32_t *)__builtin_frame_address(0);;
|
||||||
|
lastframe = NULL;
|
||||||
|
scp_offset = -(get_pc_str_offset() >> 2);
|
||||||
|
|
||||||
|
while (frame != NULL) {
|
||||||
|
db_addr_t scp;
|
||||||
|
#if 0
|
||||||
|
u_int32_t savecode;
|
||||||
|
int r;
|
||||||
|
u_int32_t *rp;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In theory, the SCP isn't guaranteed to be in the function
|
||||||
|
* that generated the stack frame. We hope for the best.
|
||||||
|
*/
|
||||||
|
scp = frame[FR_SCP];
|
||||||
|
|
||||||
|
depth++;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Switch to next frame up
|
||||||
|
*/
|
||||||
|
if (frame[FR_RFP] == 0)
|
||||||
|
break; /* Top of stack */
|
||||||
|
|
||||||
|
lastframe = frame;
|
||||||
|
frame = (u_int32_t *)(frame[FR_RFP]);
|
||||||
|
|
||||||
|
if (INKERNEL((int)frame)) {
|
||||||
|
/* staying in kernel */
|
||||||
|
if (frame <= lastframe) {
|
||||||
|
/* bad frame pointer */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (depth < aframes)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return depth - aframes;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ulong_t
|
||||||
|
dtrace_getreg(struct trapframe *rp, uint_t reg)
|
||||||
|
{
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
dtrace_copycheck(uintptr_t uaddr, uintptr_t kaddr, size_t size)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (uaddr + size > VM_MAXUSER_ADDRESS || uaddr + size < uaddr) {
|
||||||
|
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
|
||||||
|
cpu_core[curcpu].cpuc_dtrace_illval = uaddr;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dtrace_copyin(uintptr_t uaddr, uintptr_t kaddr, size_t size,
|
||||||
|
volatile uint16_t *flags)
|
||||||
|
{
|
||||||
|
if (dtrace_copycheck(uaddr, kaddr, size))
|
||||||
|
dtrace_copy(uaddr, kaddr, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dtrace_copyout(uintptr_t kaddr, uintptr_t uaddr, size_t size,
|
||||||
|
volatile uint16_t *flags)
|
||||||
|
{
|
||||||
|
if (dtrace_copycheck(uaddr, kaddr, size))
|
||||||
|
dtrace_copy(kaddr, uaddr, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dtrace_copyinstr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
|
||||||
|
volatile uint16_t *flags)
|
||||||
|
{
|
||||||
|
if (dtrace_copycheck(uaddr, kaddr, size))
|
||||||
|
dtrace_copystr(uaddr, kaddr, size, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dtrace_copyoutstr(uintptr_t kaddr, uintptr_t uaddr, size_t size,
|
||||||
|
volatile uint16_t *flags)
|
||||||
|
{
|
||||||
|
if (dtrace_copycheck(uaddr, kaddr, size))
|
||||||
|
dtrace_copystr(kaddr, uaddr, size, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t
|
||||||
|
dtrace_fuword8(void *uaddr)
|
||||||
|
{
|
||||||
|
if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) {
|
||||||
|
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
|
||||||
|
cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
return (dtrace_fuword8_nocheck(uaddr));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t
|
||||||
|
dtrace_fuword16(void *uaddr)
|
||||||
|
{
|
||||||
|
if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) {
|
||||||
|
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
|
||||||
|
cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
return (dtrace_fuword16_nocheck(uaddr));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
dtrace_fuword32(void *uaddr)
|
||||||
|
{
|
||||||
|
if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) {
|
||||||
|
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
|
||||||
|
cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
return (dtrace_fuword32_nocheck(uaddr));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t
|
||||||
|
dtrace_fuword64(void *uaddr)
|
||||||
|
{
|
||||||
|
if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) {
|
||||||
|
DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
|
||||||
|
cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
return (dtrace_fuword64_nocheck(uaddr));
|
||||||
|
}
|
187
external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c
vendored
Normal file
187
external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c
vendored
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
/*
|
||||||
|
* CDDL HEADER START
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the terms of the
|
||||||
|
* Common Development and Distribution License, Version 1.0 only
|
||||||
|
* (the "License"). You may not use this file except in compliance
|
||||||
|
* with the License.
|
||||||
|
*
|
||||||
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||||
|
* or http://www.opensolaris.org/os/licensing.
|
||||||
|
* See the License for the specific language governing permissions
|
||||||
|
* and limitations under the License.
|
||||||
|
*
|
||||||
|
* When distributing Covered Code, include this CDDL HEADER in each
|
||||||
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||||
|
* If applicable, add the following below this CDDL HEADER, with the
|
||||||
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
||||||
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
||||||
|
*
|
||||||
|
* CDDL HEADER END
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/malloc.h>
|
||||||
|
#include <sys/kmem.h>
|
||||||
|
#include <sys/smp.h>
|
||||||
|
#include <sys/dtrace_impl.h>
|
||||||
|
#include <sys/dtrace_bsd.h>
|
||||||
|
#include <machine/clock.h>
|
||||||
|
#include <machine/frame.h>
|
||||||
|
#include <machine/trap.h>
|
||||||
|
#include <vm/pmap.h>
|
||||||
|
|
||||||
|
#define DELAYBRANCH(x) ((int)(x) < 0)
|
||||||
|
|
||||||
|
extern uintptr_t dtrace_in_probe_addr;
|
||||||
|
extern int dtrace_in_probe;
|
||||||
|
extern dtrace_id_t dtrace_probeid_error;
|
||||||
|
|
||||||
|
int dtrace_invop(uintptr_t, uintptr_t *, uintptr_t);
|
||||||
|
|
||||||
|
typedef struct dtrace_invop_hdlr {
|
||||||
|
int (*dtih_func)(uintptr_t, uintptr_t *, uintptr_t);
|
||||||
|
struct dtrace_invop_hdlr *dtih_next;
|
||||||
|
} dtrace_invop_hdlr_t;
|
||||||
|
|
||||||
|
dtrace_invop_hdlr_t *dtrace_invop_hdlr;
|
||||||
|
|
||||||
|
int
|
||||||
|
dtrace_invop(uintptr_t addr, uintptr_t *stack, uintptr_t eax)
|
||||||
|
{
|
||||||
|
dtrace_invop_hdlr_t *hdlr;
|
||||||
|
int rval;
|
||||||
|
|
||||||
|
for (hdlr = dtrace_invop_hdlr; hdlr != NULL; hdlr = hdlr->dtih_next)
|
||||||
|
if ((rval = hdlr->dtih_func(addr, stack, eax)) != 0)
|
||||||
|
return (rval);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*ARGSUSED*/
|
||||||
|
void
|
||||||
|
dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit))
|
||||||
|
{
|
||||||
|
printf("IMPLEMENT ME: dtrace_toxic_ranges\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dtrace_xcall(processorid_t cpu, dtrace_xcall_t func, void *arg)
|
||||||
|
{
|
||||||
|
cpuset_t cpus;
|
||||||
|
|
||||||
|
if (cpu == DTRACE_CPUALL)
|
||||||
|
cpus = all_cpus;
|
||||||
|
else
|
||||||
|
CPU_SETOF(cpu, &cpus);
|
||||||
|
|
||||||
|
smp_rendezvous_cpus(cpus, smp_no_rendevous_barrier, func,
|
||||||
|
smp_no_rendevous_barrier, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dtrace_sync_func(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dtrace_sync(void)
|
||||||
|
{
|
||||||
|
dtrace_xcall(DTRACE_CPUALL, (dtrace_xcall_t)dtrace_sync_func, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DTrace needs a high resolution time function which can
|
||||||
|
* be called from a probe context and guaranteed not to have
|
||||||
|
* instrumented with probes itself.
|
||||||
|
*
|
||||||
|
* Returns nanoseconds since boot.
|
||||||
|
*/
|
||||||
|
uint64_t
|
||||||
|
dtrace_gethrtime()
|
||||||
|
{
|
||||||
|
struct timespec curtime;
|
||||||
|
|
||||||
|
nanouptime(&curtime);
|
||||||
|
|
||||||
|
return (curtime.tv_sec * 1000000000UL + curtime.tv_nsec);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t
|
||||||
|
dtrace_gethrestime(void)
|
||||||
|
{
|
||||||
|
struct timespec curtime;
|
||||||
|
|
||||||
|
getnanotime(&curtime);
|
||||||
|
|
||||||
|
return (curtime.tv_sec * 1000000000UL + curtime.tv_nsec);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function to handle DTrace traps during probes. See amd64/amd64/trap.c */
|
||||||
|
int
|
||||||
|
dtrace_trap(struct trapframe *frame, u_int type)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* A trap can occur while DTrace executes a probe. Before
|
||||||
|
* executing the probe, DTrace blocks re-scheduling and sets
|
||||||
|
* a flag in it's per-cpu flags to indicate that it doesn't
|
||||||
|
* want to fault. On returning from the probe, the no-fault
|
||||||
|
* flag is cleared and finally re-scheduling is enabled.
|
||||||
|
*
|
||||||
|
* Check if DTrace has enabled 'no-fault' mode:
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if ((cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0) {
|
||||||
|
/*
|
||||||
|
* There are only a couple of trap types that are expected.
|
||||||
|
* All the rest will be handled in the usual way.
|
||||||
|
*/
|
||||||
|
switch (type) {
|
||||||
|
/* Page fault. */
|
||||||
|
case 0:
|
||||||
|
/* Flag a bad address. */
|
||||||
|
cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR;
|
||||||
|
cpu_core[curcpu].cpuc_dtrace_illval = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Offset the instruction pointer to the instruction
|
||||||
|
* following the one causing the fault.
|
||||||
|
*/
|
||||||
|
panic("%s", __func__);
|
||||||
|
// frame->pc += sizeof(int);
|
||||||
|
return (1);
|
||||||
|
default:
|
||||||
|
/* Handle all other traps in the usual way. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle the trap in the usual way. */
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dtrace_probe_error(dtrace_state_t *state, dtrace_epid_t epid, int which,
|
||||||
|
int fault, int fltoffs, uintptr_t illval)
|
||||||
|
{
|
||||||
|
|
||||||
|
dtrace_probe(dtrace_probeid_error, (uint64_t)(uintptr_t)state,
|
||||||
|
(uintptr_t)epid,
|
||||||
|
(uintptr_t)which, (uintptr_t)fault, (uintptr_t)fltoffs);
|
||||||
|
}
|
62
external/cddl/osnet/dev/dtrace/arm/regset.h
vendored
Normal file
62
external/cddl/osnet/dev/dtrace/arm/regset.h
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* CDDL HEADER START
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the terms of the
|
||||||
|
* Common Development and Distribution License, Version 1.0 only
|
||||||
|
* (the "License"). You may not use this file except in compliance
|
||||||
|
* with the License.
|
||||||
|
*
|
||||||
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||||
|
* or http://www.opensolaris.org/os/licensing.
|
||||||
|
* See the License for the specific language governing permissions
|
||||||
|
* and limitations under the License.
|
||||||
|
*
|
||||||
|
* When distributing Covered Code, include this CDDL HEADER in each
|
||||||
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||||
|
* If applicable, add the following below this CDDL HEADER, with the
|
||||||
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
||||||
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
||||||
|
*
|
||||||
|
* CDDL HEADER END
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
|
||||||
|
|
||||||
|
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
|
||||||
|
/* All Rights Reserved */
|
||||||
|
|
||||||
|
#ifndef _REGSET_H
|
||||||
|
#define _REGSET_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* #pragma ident "@(#)regset.h 1.11 05/06/08 SMI"
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX: define registers properly
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#define REG_PC PC
|
||||||
|
#define REG_FP EBP
|
||||||
|
#define REG_SP SP
|
||||||
|
#define REG_PS EFL
|
||||||
|
#define REG_R0 EAX
|
||||||
|
#define REG_R1 EDX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _REGSET_H */
|
4
external/cddl/osnet/dev/lockstat/lockstat.c
vendored
4
external/cddl/osnet/dev/lockstat/lockstat.c
vendored
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: lockstat.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */
|
/* $NetBSD: lockstat.c,v 1.3 2013/06/21 19:16:00 christos Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CDDL HEADER START
|
* CDDL HEADER START
|
||||||
@ -47,7 +47,7 @@
|
|||||||
#include <sys/dtrace.h>
|
#include <sys/dtrace.h>
|
||||||
#include <sys/lockstat.h>
|
#include <sys/lockstat.h>
|
||||||
|
|
||||||
#if defined(__i386__) || defined(__amd64__)
|
#if defined(__i386__) || defined(__amd64__) || defined(__arm__)
|
||||||
#define LOCKSTAT_AFRAMES 1
|
#define LOCKSTAT_AFRAMES 1
|
||||||
#else
|
#else
|
||||||
#error "architecture not supported"
|
#error "architecture not supported"
|
||||||
|
184
external/cddl/osnet/dist/lib/libdtrace/arm/dt_isadep.c
vendored
Normal file
184
external/cddl/osnet/dist/lib/libdtrace/arm/dt_isadep.c
vendored
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
/*
|
||||||
|
* CDDL HEADER START
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the terms of the
|
||||||
|
* Common Development and Distribution License, Version 1.0 only
|
||||||
|
* (the "License"). You may not use this file except in compliance
|
||||||
|
* with the License.
|
||||||
|
*
|
||||||
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||||
|
* or http://www.opensolaris.org/os/licensing.
|
||||||
|
* See the License for the specific language governing permissions
|
||||||
|
* and limitations under the License.
|
||||||
|
*
|
||||||
|
* When distributing Covered Code, include this CDDL HEADER in each
|
||||||
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||||
|
* If applicable, add the following below this CDDL HEADER, with the
|
||||||
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
||||||
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
||||||
|
*
|
||||||
|
* CDDL HEADER END
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
#include <dt_impl.h>
|
||||||
|
#include <dt_pid.h>
|
||||||
|
|
||||||
|
#define OP(x) ((x) >> 30)
|
||||||
|
#define OP2(x) (((x) >> 22) & 0x07)
|
||||||
|
#define COND(x) (((x) >> 25) & 0x0f)
|
||||||
|
#define A(x) (((x) >> 29) & 0x01)
|
||||||
|
|
||||||
|
#define OP_BRANCH 0
|
||||||
|
|
||||||
|
#define OP2_BPcc 0x1
|
||||||
|
#define OP2_Bicc 0x2
|
||||||
|
#define OP2_BPr 0x3
|
||||||
|
#define OP2_FBPfcc 0x5
|
||||||
|
#define OP2_FBfcc 0x6
|
||||||
|
|
||||||
|
/*ARGSUSED*/
|
||||||
|
int
|
||||||
|
dt_pid_create_entry_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
|
||||||
|
fasttrap_probe_spec_t *ftp, const GElf_Sym *symp)
|
||||||
|
{
|
||||||
|
ftp->ftps_type = DTFTP_ENTRY;
|
||||||
|
ftp->ftps_pc = (uintptr_t)symp->st_value;
|
||||||
|
ftp->ftps_size = (size_t)symp->st_size;
|
||||||
|
ftp->ftps_noffs = 1;
|
||||||
|
ftp->ftps_offs[0] = 0;
|
||||||
|
|
||||||
|
if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
|
||||||
|
dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
return (dt_set_errno(dtp, errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
dt_pid_create_return_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
|
||||||
|
fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, uint64_t *stret)
|
||||||
|
{
|
||||||
|
|
||||||
|
uint32_t *text;
|
||||||
|
int i;
|
||||||
|
int srdepth = 0;
|
||||||
|
|
||||||
|
dt_dprintf("%s: unimplemented\n", __func__);
|
||||||
|
return (DT_PROC_ERR);
|
||||||
|
|
||||||
|
if ((text = malloc(symp->st_size + 4)) == NULL) {
|
||||||
|
dt_dprintf("mr sparkle: malloc() failed\n");
|
||||||
|
return (DT_PROC_ERR);
|
||||||
|
}
|
||||||
|
#ifdef DOODAD
|
||||||
|
if (Pread(P, text, symp->st_size, symp->st_value) != symp->st_size) {
|
||||||
|
dt_dprintf("mr sparkle: Pread() failed\n");
|
||||||
|
free(text);
|
||||||
|
return (DT_PROC_ERR);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Leave a dummy instruction in the last slot to simplify edge
|
||||||
|
* conditions.
|
||||||
|
*/
|
||||||
|
text[symp->st_size / 4] = 0;
|
||||||
|
|
||||||
|
ftp->ftps_type = DTFTP_RETURN;
|
||||||
|
ftp->ftps_pc = symp->st_value;
|
||||||
|
ftp->ftps_size = symp->st_size;
|
||||||
|
ftp->ftps_noffs = 0;
|
||||||
|
|
||||||
|
|
||||||
|
free(text);
|
||||||
|
if (ftp->ftps_noffs > 0) {
|
||||||
|
if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
|
||||||
|
dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
return (dt_set_errno(dtp, errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return (ftp->ftps_noffs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*ARGSUSED*/
|
||||||
|
int
|
||||||
|
dt_pid_create_offset_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
|
||||||
|
fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, ulong_t off)
|
||||||
|
{
|
||||||
|
if (off & 0x3)
|
||||||
|
return (DT_PROC_ALIGN);
|
||||||
|
|
||||||
|
ftp->ftps_type = DTFTP_OFFSETS;
|
||||||
|
ftp->ftps_pc = (uintptr_t)symp->st_value;
|
||||||
|
ftp->ftps_size = (size_t)symp->st_size;
|
||||||
|
ftp->ftps_noffs = 1;
|
||||||
|
ftp->ftps_offs[0] = off;
|
||||||
|
|
||||||
|
if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
|
||||||
|
dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
return (dt_set_errno(dtp, errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*ARGSUSED*/
|
||||||
|
int
|
||||||
|
dt_pid_create_glob_offset_probes(struct ps_prochandle *P, dtrace_hdl_t *dtp,
|
||||||
|
fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, const char *pattern)
|
||||||
|
{
|
||||||
|
ulong_t i;
|
||||||
|
|
||||||
|
ftp->ftps_type = DTFTP_OFFSETS;
|
||||||
|
ftp->ftps_pc = (uintptr_t)symp->st_value;
|
||||||
|
ftp->ftps_size = (size_t)symp->st_size;
|
||||||
|
ftp->ftps_noffs = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we're matching against everything, just iterate through each
|
||||||
|
* instruction in the function, otherwise look for matching offset
|
||||||
|
* names by constructing the string and comparing it against the
|
||||||
|
* pattern.
|
||||||
|
*/
|
||||||
|
if (strcmp("*", pattern) == 0) {
|
||||||
|
for (i = 0; i < symp->st_size; i += 4) {
|
||||||
|
ftp->ftps_offs[ftp->ftps_noffs++] = i;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
char name[sizeof (i) * 2 + 1];
|
||||||
|
|
||||||
|
for (i = 0; i < symp->st_size; i += 4) {
|
||||||
|
(void) sprintf(name, "%lx", i);
|
||||||
|
if (gmatch(name, pattern))
|
||||||
|
ftp->ftps_offs[ftp->ftps_noffs++] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
|
||||||
|
dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
return (dt_set_errno(dtp, errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ftp->ftps_noffs);
|
||||||
|
}
|
||||||
|
|
94
external/cddl/osnet/dist/uts/arm/sys/fasttrap_isa.h
vendored
Normal file
94
external/cddl/osnet/dist/uts/arm/sys/fasttrap_isa.h
vendored
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* CDDL HEADER START
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the terms of the
|
||||||
|
* Common Development and Distribution License, Version 1.0 only
|
||||||
|
* (the "License"). You may not use this file except in compliance
|
||||||
|
* with the License.
|
||||||
|
*
|
||||||
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||||
|
* or http://www.opensolaris.org/os/licensing.
|
||||||
|
* See the License for the specific language governing permissions
|
||||||
|
* and limitations under the License.
|
||||||
|
*
|
||||||
|
* When distributing Covered Code, include this CDDL HEADER in each
|
||||||
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||||
|
* If applicable, add the following below this CDDL HEADER, with the
|
||||||
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
||||||
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
||||||
|
*
|
||||||
|
* CDDL HEADER END
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||||
|
* Use is subject to license terms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _FASTTRAP_ISA_H
|
||||||
|
#define _FASTTRAP_ISA_H
|
||||||
|
|
||||||
|
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is our reserved trap instruction: ta 0x38
|
||||||
|
*/
|
||||||
|
#define FASTTRAP_INSTR 0x91d02038
|
||||||
|
|
||||||
|
#define FASTTRAP_SUNWDTRACE_SIZE 128
|
||||||
|
|
||||||
|
typedef uint32_t fasttrap_instr_t;
|
||||||
|
|
||||||
|
typedef struct fasttrap_machtp {
|
||||||
|
fasttrap_instr_t ftmt_instr; /* original instruction */
|
||||||
|
uintptr_t ftmt_dest; /* destination of DCTI */
|
||||||
|
uint8_t ftmt_type; /* emulation type */
|
||||||
|
uint8_t ftmt_flags; /* emulation flags */
|
||||||
|
uint8_t ftmt_cc; /* which cc to look at */
|
||||||
|
uint8_t ftmt_code; /* branch condition */
|
||||||
|
} fasttrap_machtp_t;
|
||||||
|
|
||||||
|
#define ftt_instr ftt_mtp.ftmt_instr
|
||||||
|
#define ftt_dest ftt_mtp.ftmt_dest
|
||||||
|
#define ftt_type ftt_mtp.ftmt_type
|
||||||
|
#define ftt_flags ftt_mtp.ftmt_flags
|
||||||
|
#define ftt_cc ftt_mtp.ftmt_cc
|
||||||
|
#define ftt_code ftt_mtp.ftmt_code
|
||||||
|
|
||||||
|
#define FASTTRAP_T_COMMON 0x00 /* common case -- no emulation */
|
||||||
|
#define FASTTRAP_T_CCR 0x01 /* integer condition code branch */
|
||||||
|
#define FASTTRAP_T_FCC 0x02 /* floating-point branch */
|
||||||
|
#define FASTTRAP_T_REG 0x03 /* register predicated branch */
|
||||||
|
#define FASTTRAP_T_ALWAYS 0x04 /* branch always */
|
||||||
|
#define FASTTRAP_T_CALL 0x05 /* call instruction */
|
||||||
|
#define FASTTRAP_T_JMPL 0x06 /* jmpl instruction */
|
||||||
|
#define FASTTRAP_T_RDPC 0x07 /* rdpc instruction */
|
||||||
|
#define FASTTRAP_T_RETURN 0x08 /* return instruction */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For performance rather than correctness.
|
||||||
|
*/
|
||||||
|
#define FASTTRAP_T_SAVE 0x10 /* save instruction (func entry only) */
|
||||||
|
#define FASTTRAP_T_RESTORE 0x11 /* restore instruction */
|
||||||
|
#define FASTTRAP_T_OR 0x12 /* mov instruction */
|
||||||
|
#define FASTTRAP_T_SETHI 0x13 /* sethi instruction (includes nop) */
|
||||||
|
|
||||||
|
#define FASTTRAP_F_ANNUL 0x01 /* branch is annulled */
|
||||||
|
#define FASTTRAP_F_RETMAYBE 0x02 /* not definitely a return site */
|
||||||
|
|
||||||
|
#define FASTTRAP_AFRAMES 3
|
||||||
|
#define FASTTRAP_RETURN_AFRAMES 4
|
||||||
|
#define FASTTRAP_ENTRY_AFRAMES 3
|
||||||
|
#define FASTTRAP_OFFSET_AFRAMES 3
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _FASTTRAP_ISA_H */
|
6
external/cddl/osnet/lib/libdtrace/Makefile
vendored
6
external/cddl/osnet/lib/libdtrace/Makefile
vendored
@ -1,4 +1,4 @@
|
|||||||
# $NetBSD: Makefile,v 1.6 2012/02/13 12:52:54 wiz Exp $
|
# $NetBSD: Makefile,v 1.7 2013/06/21 19:16:01 christos Exp $
|
||||||
|
|
||||||
# $FreeBSD: src/cddl/lib/libdtrace/Makefile,v 1.2.2.1 2009/08/03 08:13:06 kensmith Exp $
|
# $FreeBSD: src/cddl/lib/libdtrace/Makefile,v 1.2.2.1 2009/08/03 08:13:06 kensmith Exp $
|
||||||
|
|
||||||
@ -86,6 +86,10 @@ COPTS.dt_subr.c += -Wno-stack-protector
|
|||||||
CPPFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/intel
|
CPPFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/intel
|
||||||
.elif ${MACHINE_ARCH} == "sparc64"
|
.elif ${MACHINE_ARCH} == "sparc64"
|
||||||
CPPFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/sparc
|
CPPFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/sparc
|
||||||
|
.elif ${MACHINE_ARCH} == "arm"
|
||||||
|
CPPFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/arm
|
||||||
|
.PATH: ${.CURDIR}/../../dist/lib/libdtrace/arm
|
||||||
|
SRCS+= dt_isadep.c
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
LFLAGS+=-l
|
LFLAGS+=-l
|
||||||
|
5
external/cddl/osnet/lib/libzpool/Makefile
vendored
5
external/cddl/osnet/lib/libzpool/Makefile
vendored
@ -1,4 +1,4 @@
|
|||||||
# $NetBSD: Makefile,v 1.6 2010/12/14 23:39:11 haad Exp $
|
# $NetBSD: Makefile,v 1.7 2013/06/21 19:16:01 christos Exp $
|
||||||
|
|
||||||
.include "${.CURDIR}/../../dist/uts/common/Makefile.files"
|
.include "${.CURDIR}/../../dist/uts/common/Makefile.files"
|
||||||
.include "../../Makefile.zfs"
|
.include "../../Makefile.zfs"
|
||||||
@ -17,6 +17,9 @@ CPPFLAGS+= -std=c99
|
|||||||
|
|
||||||
# Local stuff
|
# Local stuff
|
||||||
SRCS= kernel.c kernel2.c
|
SRCS= kernel.c kernel2.c
|
||||||
|
.if ${MACHINE_ARCH} == "arm"
|
||||||
|
SRCS+= atomic.c
|
||||||
|
.endif
|
||||||
|
|
||||||
# Sun stuff
|
# Sun stuff
|
||||||
SRCS+= ${ZFS_COMMON_OBJS:C/.o$/.c/}
|
SRCS+= ${ZFS_COMMON_OBJS:C/.o$/.c/}
|
||||||
|
32
external/cddl/osnet/lib/libzpool/atomic.c
vendored
Normal file
32
external/cddl/osnet/lib/libzpool/atomic.c
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <sys/atomic.h>
|
||||||
|
|
||||||
|
/* XXX: Not so atomic, could use mutexes but not worth it */
|
||||||
|
uint64_t
|
||||||
|
atomic_cas_64(volatile uint64_t *ptr, uint64_t old, uint64_t new) {
|
||||||
|
uint64_t prev = *ptr;
|
||||||
|
if (prev == old)
|
||||||
|
*ptr = new;
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
atomic_add_64(volatile uint64_t *ptr, int64_t delta) {
|
||||||
|
*ptr += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
atomic_inc_64(volatile uint64_t *ptr) {
|
||||||
|
++(*ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
atomic_dec_64(volatile uint64_t *ptr) {
|
||||||
|
--(*ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t
|
||||||
|
atomic_add_64_nv(volatile uint64_t *ptr, int64_t delta) {
|
||||||
|
return *ptr += delta;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user