• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1COMMENT @
2 <copyright>
3  This file is provided under a dual BSD/GPLv2 license.  When using or
4  redistributing this file, you may do so under either license.
5
6  GPL LICENSE SUMMARY
7
8  Copyright (c) 2017-2020 Intel Corporation. All rights reserved.
9
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of version 2 of the GNU General Public License as
12  published by the Free Software Foundation.
13
14  This program is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
22  The full GNU General Public License is included in this distribution
23  in the file called LICENSE.GPL.
24
25  Contact Information:
26  http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/
27
28  BSD LICENSE
29
30  Copyright (c) 2017-2020 Intel Corporation. All rights reserved.
31  All rights reserved.
32
33  Redistribution and use in source and binary forms, with or without
34  modification, are permitted provided that the following conditions
35  are met:
36
37    * Redistributions of source code must retain the above copyright
38      notice, this list of conditions and the following disclaimer.
39    * Redistributions in binary form must reproduce the above copyright
40      notice, this list of conditions and the following disclaimer in
41      the documentation and/or other materials provided with the
42      distribution.
43    * Neither the name of Intel Corporation nor the names of its
44      contributors may be used to endorse or promote products derived
45      from this software without specific prior written permission.
46
47  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
50  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
51  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
55  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
57  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58</copyright>
59@
60
61;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
62;;; ;;; Intel Processor Trace Marker Functionality
63;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
64
65
66_TEXT	segment
67
68        public	__itt_pt_mark
69        public	__itt_pt_event
70        public	__itt_pt_mark_event
71        public  __itt_pt_mark_threshold
72        public  __itt_pt_write
73        public  __itt_pt_byte
74
75        align   10h
76
77;;; void __itt_pt_mark(unsigned char index);
78
79__itt_pt_mark   proc
80
81        and     rcx,0ffh
82        lea     r10,offset __itt_pt_mark_call_table
83        lea     rcx,[r10 + rcx * 4]
84        jmp	rcx
85
86        align   04h
87
88        dd      0, 1, 2, 3      ;;; GUID
89
90        dd      0fadefadeh      ;;; magic marker
91
92__itt_pt_mark_call_table:
93
94        dd      256 dup(0000c2c3h OR (( $ - offset __itt_pt_mark_call_table) SHL 14))
95
96__itt_pt_mark   endp
97
98        align   10h
99
100__itt_pt_byte   proc
101
102        and     rcx,0ffh
103        lea     r10,offset __itt_pt_byte_call_table
104        add     rcx,r10
105        jmp     rcx
106
107        align   04h
108
109        dd      0, 1, 2, 3      ;;; GUID
110
111        dd      0fadedeafh      ;;; magic marker
112
113__itt_pt_byte_call_table:
114
115        db      256 dup(0c3h)
116
117__itt_pt_byte   endp
118
119        align   10h
120
121__itt_pt_event  proc
122
123        rdpmc
124
125        mov     cl,al
126        call    __itt_pt_byte
127        mov     cl,ah
128        call    __itt_pt_byte
129        shr     eax,16
130        mov     cl,al
131        call    __itt_pt_byte
132        mov     cl,ah
133        call    __itt_pt_byte
134
135        mov     cl,dl
136        call    __itt_pt_byte
137        mov     cl,dh
138        call    __itt_pt_byte
139        shr     edx,16
140        mov     cl,dl
141        call    __itt_pt_byte
142        mov     cl,dh
143        call    __itt_pt_byte
144
145        ret
146
147__itt_pt_event  endp
148
149        align   10h
150
151__itt_pt_mark_event     proc
152
153        test    rcx,1
154        jnz     odd
155        mov     r8,rcx
156        xor     rcx,rcx
157        call    __itt_pt_event
158        mov     rcx,r8
159        jmp     __itt_pt_mark
160
161odd:
162        call    __itt_pt_mark
163        xor     rcx,rcx
164        jmp     __itt_pt_event
165
166__itt_pt_mark_event     endp
167
168        align   10h
169
170__itt_pt_flush  proc
171
172        lea     rax,offset __itt_pt_mark_flush_1
173        jmp     rax
174
175        align   10h
176        nop
177__itt_pt_mark_flush_1:
178        lea     rax,offset __itt_pt_mark_flush_2
179        jmp     rax
180
181        align   10h
182        nop
183        nop
184__itt_pt_mark_flush_2:
185        lea     rax,offset __itt_pt_mark_flush_3
186        jmp     rax
187
188        align   10h
189        nop
190        nop
191        nop
192__itt_pt_mark_flush_3:
193        ret
194
195__itt_pt_flush  endp
196
197        align   10h
198
199;;; int __itt_pt_mark_threshold(unsigned char index, unsigned long long* tmp, int threshold);
200
201__itt_pt_mark_threshold proc
202        mov     r9,rcx  ;;; index
203        mov     r10,rdx ;;; tmp
204        xor     rdx,rdx
205        xor     rax,rax
206        test    rcx,1
207        jnz     mark_end
208mark_begin:
209        mov     rcx,(1 SHL 30) + 1
210        rdpmc
211        shl     rdx,32
212        or      rdx,rax
213        mov     [r10],rdx
214        mov     rcx,r9
215        jmp     __itt_pt_mark
216mark_end:
217        mov     rcx,(1 SHL 30) + 1
218        rdpmc
219        shl     rdx,32
220        or      rdx,rax
221        sub     rdx,[r10]
222        cmp     rdx,r8  ;;; threshold
223        mov     rcx,r9
224        jnc     found
225        jmp     __itt_pt_mark
226found:
227        call    __itt_pt_mark
228        jmp     __itt_pt_flush
229
230__itt_pt_mark_threshold endp
231
232;;; PTWRITE
233
234        align   10h
235
236;;; void __itt_pt_write(unsigned long long value);
237
238        dd      0, 1, 2, 3      ;;; GUID
239
240__itt_pt_write  proc
241
242;;;        ptwrite rcx
243        db      0F3h, 48h, 0Fh, 0AEh, 0E1h
244        ret
245
246__itt_pt_write  endp
247
248;;;
249
250_TEXT	ends
251        end
252