Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/cddl/dev/dtrace/powerpc/dtrace_asm.S
48375 views
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 <[email protected]>
23
*/
24
/*
25
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
26
* Use is subject to license terms.
27
*/
28
29
#include "assym.inc"
30
31
#define _ASM
32
33
#include <sys/cpuvar_defs.h>
34
#include <sys/dtrace.h>
35
36
#include <machine/asm.h>
37
/*
38
#include <machine/cpu.h>
39
*/
40
41
/*
42
* Primitives
43
*/
44
45
.text
46
47
/*
48
void dtrace_membar_producer(void)
49
*/
50
ASENTRY_NOPROF(dtrace_membar_producer)
51
sync
52
blr
53
END(dtrace_membar_producer)
54
55
/*
56
void dtrace_membar_consumer(void)
57
*/
58
ASENTRY_NOPROF(dtrace_membar_consumer)
59
isync
60
blr
61
END(dtrace_membar_consumer)
62
63
/*
64
dtrace_icookie_t dtrace_interrupt_disable(void)
65
*/
66
ASENTRY_NOPROF(dtrace_interrupt_disable)
67
mfmsr %r3
68
#ifdef __powerpc64__
69
/* Two-instruction sequence to clear EE flag */
70
rldicl %r0,%r3,48,1
71
rotldi %r0,%r0,16
72
#else
73
rlwinm %r0,%r3,0,17,15 /* Clear EE flag */
74
#endif
75
mtmsr %r0
76
blr
77
END(dtrace_interrupt_disable)
78
79
/*
80
void dtrace_interrupt_enable(dtrace_icookie_t cookie)
81
*/
82
ASENTRY_NOPROF(dtrace_interrupt_enable)
83
mtmsr %r3
84
blr
85
END(dtrace_interrupt_enable)
86
87
/*
88
uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
89
*/
90
ASENTRY_NOPROF(dtrace_cas32)
91
1:
92
lwarx %r0,0,%r3
93
cmpw %r4,%r0
94
bne 2f
95
stwcx. %r5,0,%r3
96
bne 1b
97
2: mr %r3,%r0
98
blr
99
END(dtrace_cas32)
100
101
/*
102
void *
103
dtrace_casptr(void *target, void *cmp, void *new)
104
*/
105
ASENTRY_NOPROF(dtrace_casptr)
106
#ifdef __powerpc64__
107
1:
108
ldarx %r0,0,%r3
109
cmpd %r4,%r0
110
bne 2f
111
stdcx. %r5,0,%r3
112
bne 1b
113
#else
114
1:
115
lwarx %r0,0,%r3
116
cmpw %r4,%r0
117
bne 2f
118
stwcx. %r5,0,%r3
119
bne 1b
120
#endif
121
2: mr %r3,%r0
122
blr
123
END(dtrace_casptr)
124
125
126
/*
127
XXX: unoptimized
128
void
129
dtrace_copy(uintptr_t src, uintptr_t dest, size_t size)
130
*/
131
ASENTRY_NOPROF(dtrace_copy)
132
subi %r7,%r3,1
133
subi %r8,%r4,1
134
mtctr %r5
135
1:
136
lbzu %r3,1(%r7)
137
stbu %r3,1(%r8)
138
bdnz 1b
139
2:
140
blr
141
END(dtrace_copy)
142
143
/*
144
void
145
dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
146
volatile uint16_t *flags)
147
*/
148
ASENTRY_NOPROF(dtrace_copystr)
149
subi %r7,%r3,1
150
subi %r8,%r4,1
151
1:
152
lbzu %r3,1(%r7)
153
stbu %r3,1(%r8)
154
subi %r5,%r5,1
155
#ifdef __powerpc64__
156
cmpldi %r5,0
157
#else
158
cmplwi %r5,0
159
#endif
160
beq 2f
161
cmplwi %r3,0
162
beq 2f
163
andi. %r0,%r5,0x0fff
164
beq 2f
165
lwz %r0,0(%r6)
166
andi. %r0,%r0,CPU_DTRACE_BADADDR
167
beq 1b
168
2:
169
blr
170
END(dtrace_copystr)
171
172
/*
173
uintptr_t
174
dtrace_caller(int aframes)
175
*/
176
ASENTRY_NOPROF(dtrace_caller)
177
li %r3, -1
178
blr
179
END(dtrace_caller)
180
181
/*
182
greg_t
183
dtrace_getfp(void)
184
*/
185
ASENTRY_NOPROF(dtrace_getfp)
186
mr %r3,%r31
187
blr
188
END(dtrace_getfp)
189
190
191