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.686p 66.xmm 67.model FLAT 68 69_TEXT segment 70 71 public ___itt_pt_mark 72 public ___itt_pt_event 73 public ___itt_pt_mark_event 74 public ___itt_pt_mark_threshold 75 public ___itt_pt_write 76 public ___itt_pt_byte 77 78 align 10h 79 80;;; void __itt_pt_mark(unsigned char index); 81 82___itt_pt_mark proc near 83 84 movzx eax,byte ptr [esp + 4] 85 lea eax,__itt_pt_mark_call_table[eax * 4] 86 jmp eax 87 88 align 04h 89 90 dd 0, 1, 2, 3 ;;; GUID 91 92 dd 0fadefadeh ;;; magic marker 93 94__itt_pt_mark_call_table: 95 96 dd 256 dup(0000c2c3h OR (( $ - offset __itt_pt_mark_call_table) SHL 14)) 97 98___itt_pt_mark endp 99 100 101___itt_pt_byte proc near 102 103 mov ecx,[esp + 4] 104 105___itt_pt_byte_:: 106 107 and ecx,0ffh 108 lea ecx,__itt_pt_byte_call_table[ecx] 109 jmp ecx 110 111 align 04h 112 113 dd 0, 1, 2, 3 ;;; GUID 114 115 dd 0fadedeafh ;;; magic marker 116 117__itt_pt_byte_call_table: 118 119 db 256 dup(0c3h) 120 121___itt_pt_byte endp 122 123 align 10h 124 125___itt_pt_event proc near 126 127 push ecx 128 mov ecx,[esp + 8] 129 rdpmc 130 131 mov cl,al 132 call ___itt_pt_byte_ 133 mov cl,ah 134 call ___itt_pt_byte_ 135 shr eax,16 136 mov cl,al 137 call ___itt_pt_byte_ 138 mov cl,ah 139 call ___itt_pt_byte_ 140 141 mov cl,dl 142 call ___itt_pt_byte_ 143 mov cl,dh 144 call ___itt_pt_byte_ 145 shr edx,16 146 mov cl,dl 147 call ___itt_pt_byte_ 148 mov cl,dh 149 call ___itt_pt_byte_ 150 151 pop ecx 152 ret 153 154___itt_pt_event endp 155 156 align 10h 157 158___itt_pt_mark_event proc near 159 160 test byte ptr [esp + 4],1 161 jnz odd 162 push 0 163 call ___itt_pt_event 164 add esp,4 165 jmp ___itt_pt_mark 166 167odd: 168 push dword ptr [esp + 4] 169 call ___itt_pt_mark 170 add esp,4 171 mov dword ptr [esp + 4],0 172 jmp ___itt_pt_event 173 174___itt_pt_mark_event endp 175 176 align 10h 177 178___itt_pt_flush proc near 179 180 lea eax,offset __itt_pt_mark_flush_1 181 jmp eax 182 183 align 10h 184 nop 185__itt_pt_mark_flush_1: 186 lea eax,offset __itt_pt_mark_flush_2 187 jmp eax 188 189 align 10h 190 nop 191 nop 192__itt_pt_mark_flush_2: 193 lea eax,offset __itt_pt_mark_flush_3 194 jmp eax 195 196 align 10h 197 nop 198 nop 199 nop 200__itt_pt_mark_flush_3: 201 ret 202 203___itt_pt_flush endp 204 205 align 10h 206 207;;; int __itt_pt_mark_threshold(unsigned char index, unsigned long long* tmp, int threshold); 208 209___itt_pt_mark_threshold proc near 210 test byte ptr [esp + 4],1 ;;; index 211 jnz mark_end 212mark_begin: 213 mov ecx,(1 SHL 30) + 1 214 rdpmc 215 mov ecx,[esp + 8] ;;; tmp 216 mov [ecx + 0],eax 217 mov [ecx + 4],edx 218 jmp ___itt_pt_mark 219mark_end: 220 mov ecx,(1 SHL 30) + 1 221 rdpmc 222 mov ecx,[esp + 8] ;;; tmp 223 sub eax,[ecx + 0] 224 sbb edx,[ecx + 4] 225 or edx,edx 226 jnz found 227 cmp edx,[esp + 12] ;;; threshold 228 jnc found 229 jmp ___itt_pt_mark 230found: 231 call ___itt_pt_mark 232 jmp ___itt_pt_flush 233 234___itt_pt_mark_threshold endp 235 236;;; PTWRITE 237 238 align 10h 239 240;;; void __itt_pt_write(unsigned long long value); 241 242 dd 0, 1, 2, 3 ;;; GUID 243 244___itt_pt_write proc 245 246;;; ptwrite dword ptr [esp + 4] 247 db 0F3h, 0Fh, 0AEh, 64h, 24h, 04h 248 ret 249 250___itt_pt_write endp 251 252;;; 253 254_TEXT ends 255 end 256