1 /* 2 * SPDX-FileCopyrightText: Copyright (c) 2012-2021 NVIDIA CORPORATION & AFFILIATES 3 * SPDX-License-Identifier: MIT 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 #ifndef _NVLOG_DEFS_H_ 24 #define _NVLOG_DEFS_H_ 25 26 #include "nvtypes.h" 27 /******************* Common Debug & Trace Defines ***************************\ 28 * * 29 * Module: NVLOG_DEFS.H * 30 * * 31 \****************************************************************************/ 32 33 #define NVLOG_MAX_DBG_MODULES 256 34 35 /********************************/ 36 /********* Structures *********/ 37 /********************************/ 38 39 // Forward declaration, so it can be used in the function type definition. 40 41 /** 42 * @brief Struct representing a buffer in NvLog 43 * 44 * All logging (Print, Regtrace, etc) use these buffers. 45 */ 46 typedef struct _NVLOG_BUFFER NVLOG_BUFFER; 47 48 49 /** 50 * @brief Type of the 'push' function for NvLog buffers 51 * 52 * Function called whenever pushing something to an NvLog buffer 53 */ 54 typedef NvBool (*NVLOG_BUFFER_PUSHFUNC) (NVLOG_BUFFER *, NvU8 *, NvU32); 55 56 57 58 /** 59 * @brief Fields specific to ring buffers 60 */ 61 typedef struct _NVLOG_RING_BUFFER_EXTRA_FIELDS 62 { 63 /** How many times the ring buffer has overflown */ 64 NvU32 overflow; 65 } NVLOG_RING_BUFFER_EXTRA_FIELDS; 66 67 68 /** 69 * @brief Struct representing a buffer in NvLog 70 * 71 * All logging (Print, Regtrace, etc) use these buffers. 72 */ 73 struct _NVLOG_BUFFER 74 { 75 /** Function to call when writing to this buffer */ 76 union 77 { 78 NVLOG_BUFFER_PUSHFUNC fn; 79 80 // Pad this union to prevent struct size from varying between 32/64 bit platforms 81 NvP64 padding; 82 } push; 83 84 /** Size of the buffer data section */ 85 NvU32 size; 86 /** Buffer tag, for easier identification in a dump */ 87 NvU32 tag; 88 /** Flags of the buffer, following NVLOG_BUFFER_FLAGS_* DRF's */ 89 NvU32 flags; 90 /** Position of the next available byte in the buffer */ 91 NvU32 pos; 92 /** Number of threads currently writing to this buffer */ 93 volatile NvS32 threadCount; 94 /** Specific buffer types will define their fields here */ 95 union 96 { 97 NVLOG_RING_BUFFER_EXTRA_FIELDS ring; 98 } extra; 99 /** Buffer data. */ 100 NvU8 data[1]; 101 }; 102 103 #define NVLOG_MAX_BUFFERS_v11 16 104 #define NVLOG_MAX_BUFFERS_v12 256 105 106 #define NVLOG_MAX_BUFFERS NVLOG_MAX_BUFFERS_v12 107 #define NVLOG_LOGGER_VERSION 12 // v1.2 108 109 // Due to this file's peculiar location, NvPort may or may not be includable 110 typedef struct PORT_SPINLOCK PORT_SPINLOCK; 111 typedef struct PORT_MUTEX PORT_MUTEX; 112 typedef struct PORT_RWLOCK PORT_RWLOCK; 113 114 #if PORT_IS_KERNEL_BUILD 115 #include "nvport/nvport.h" 116 #endif 117 118 /** 119 * @brief Information about the entire NvLog system 120 */ 121 typedef struct _NVLOG_LOGGER 122 { 123 /** NvLog logger version */ 124 NvU32 version; 125 /** Logging buffers */ 126 NVLOG_BUFFER * pBuffers[NVLOG_MAX_BUFFERS]; 127 /** Index of the first unallocated buffer */ 128 NvU32 nextFree; 129 /** Total number of free buffer slots */ 130 NvU32 totalFree; 131 /** Lock for some buffer oprations */ 132 PORT_SPINLOCK* mainLock; 133 /** Lock for creating/deleting pBuffers and accessing them from RmCtrls */ 134 PORT_MUTEX* buffersLock; 135 /** Lock for registering/deregistering flush callbacks */ 136 PORT_RWLOCK *flushCbsLock; 137 } NVLOG_LOGGER; 138 extern NVLOG_LOGGER NvLogLogger; 139 140 /** 141 * NvLog uses two locks: 142 * - NVLOG_LOGGER::mainLock is used to protect some accesses to pBuffers, or 143 * an individual pBuffers entry depending on locking flags. 144 * - NVLOG_LOGGER::buffersLock is used to protect creating/deleting pBuffers and accessing them 145 * from certain RmCtrl handlers. 146 * 147 * Historically in most contexts obtaining RMAPI lock would suffice, and mainLock would optionally 148 * be used for certain buffers. Ioctl NV_ESC_RM_LOCKLESS_DIAGNOSTIC cannot touch RMAPI lock and needs 149 * to access NvLog. The latter operation might race if called at an inopportune time: e.g. if the 150 * ioctl is called during RM init when KGSP creates/deletes GSP NvLog buffers. Using buffersLock is 151 * thus necessary to resolve the potential race. 152 * 153 * This leads to an unfortunate sequence where mainLock and buffersLock are nested. The latter lock 154 * cannot be removed as it is used in IRQ paths. 155 * 156 * This should be refactored to use a single RWLock that does conditional acquire in possible IRQ 157 * paths. 158 */ 159 160 // 161 // Buffer flags 162 // 163 164 // Logging to this buffer is disabled 165 #define NVLOG_BUFFER_FLAGS_DISABLED 0:0 166 #define NVLOG_BUFFER_FLAGS_DISABLED_NO 0 167 #define NVLOG_BUFFER_FLAGS_DISABLED_YES 1 168 169 #define NVLOG_BUFFER_FLAGS_TYPE 2:1 170 #define NVLOG_BUFFER_FLAGS_TYPE_RING 0 171 #define NVLOG_BUFFER_FLAGS_TYPE_NOWRAP 1 172 #define NVLOG_BUFFER_FLAGS_TYPE_SYSTEMLOG 2 173 174 // Expand buffer when full 175 #define NVLOG_BUFFER_FLAGS_EXPANDABLE 3:3 176 #define NVLOG_BUFFER_FLAGS_EXPANDABLE_NO 0 177 #define NVLOG_BUFFER_FLAGS_EXPANDABLE_YES 1 178 179 // Allocate buffer in non paged memory 180 #define NVLOG_BUFFER_FLAGS_NONPAGED 4:4 181 #define NVLOG_BUFFER_FLAGS_NONPAGED_NO 0 182 #define NVLOG_BUFFER_FLAGS_NONPAGED_YES 1 183 184 // 185 // Type of buffer locking to use 186 // NONE - No locking performed, for buffers that are inherently single threaded 187 // STATE - Lock only during state change, do memory copying unlocked 188 // Don't use with tiny buffers that overflow every write or two. 189 // FULL - Keep everything locked for the full duration of the write 190 // 191 #define NVLOG_BUFFER_FLAGS_LOCKING 6:5 192 #define NVLOG_BUFFER_FLAGS_LOCKING_NONE 0 193 #define NVLOG_BUFFER_FLAGS_LOCKING_STATE 1 194 #define NVLOG_BUFFER_FLAGS_LOCKING_FULL 2 195 196 // Store this buffer in OCA minidumps 197 #define NVLOG_BUFFER_FLAGS_OCA 7:7 198 #define NVLOG_BUFFER_FLAGS_OCA_NO 0 199 #define NVLOG_BUFFER_FLAGS_OCA_YES 1 200 201 // Buffer format (not included in registry key) 202 #define NVLOG_BUFFER_FLAGS_FORMAT 10:8 203 #define NVLOG_BUFFER_FLAGS_FORMAT_PRINTF 0 204 #define NVLOG_BUFFER_FLAGS_FORMAT_LIBOS_LOG 1 205 #define NVLOG_BUFFER_FLAGS_FORMAT_MEMTRACK 2 206 207 // Never deallocate this buffer until RM is unloaded 208 #define NVLOG_BUFFER_FLAGS_PRESERVE 11:11 209 #define NVLOG_BUFFER_FLAGS_PRESERVE_NO 0 210 #define NVLOG_BUFFER_FLAGS_PRESERVE_YES 1 211 212 // Buffer GPU index 213 #define NVLOG_BUFFER_FLAGS_GPU_INSTANCE 31:24 214 215 typedef NvU32 NVLOG_BUFFER_HANDLE; 216 217 // 218 // Utility macros 219 // 220 #define NVLOG_IS_RING_BUFFER(pBuffer) \ 221 FLD_TEST_DRF(LOG_BUFFER, _FLAGS, _TYPE, _RING, pBuffer->flags) 222 #define NVLOG_IS_NOWRAP_BUFFER(pBuffer) \ 223 FLD_TEST_DRF(LOG_BUFFER, _FLAGS, _TYPE, _NOWRAP, pBuffer->flags) 224 225 #define NVLOG_PRINT_BUFFER_SIZE(pBuffer) ((pBuffer)->size) 226 #define NVLOG_BUFFER_SIZE(pBuffer) \ 227 (NV_OFFSETOF(NVLOG_BUFFER, data) + NVLOG_PRINT_BUFFER_SIZE(pBuffer)) 228 229 /********************************/ 230 /********* Filtering **********/ 231 /********************************/ 232 // TODO - Remove all this once tools are updated 233 234 #define NVLOG_FILTER_INVALID (~0) 235 236 #define NVLOG_FILTER_VALUE_SIMPLE_NO 0x0 237 #define NVLOG_FILTER_VALUE_SIMPLE_YES 0x1 238 #define NVLOG_FILTER_VALUE_EXPLICIT_NO 0x2 239 #define NVLOG_FILTER_VALUE_EXPLICIT_YES 0x3 240 241 #define NVLOG_FILTER_PRINT_LEVEL_REGTRACE 1:0 242 #define NVLOG_FILTER_PRINT_LEVEL_INFO 3:2 243 #define NVLOG_FILTER_PRINT_LEVEL_NOTICE 5:4 244 #define NVLOG_FILTER_PRINT_LEVEL_WARNINGS 7:6 245 #define NVLOG_FILTER_PRINT_LEVEL_ERRORS 9:8 246 #define NVLOG_FILTER_PRINT_LEVEL_HW_ERROR 11:10 247 #define NVLOG_FILTER_PRINT_LEVEL_FATAL 13:12 248 249 #define NVLOG_FILTER_PRINT_BUFFER 18:14 250 #define NVLOG_FILTER_REGTRACE_BUFFER 22:19 251 252 #define NVLOG_FILTER_REGTRACE_LOG_READ 25:23 253 #define NVLOG_FILTER_REGTRACE_LOG_WRITE 27:26 254 #define NVLOG_FILTER_REGTRACE_BREAK_READ 29:28 255 #define NVLOG_FILTER_REGTRACE_BREAK_WRITE 31:30 256 257 #define NVLOG_FILTER_VALUE_IS_NO(val) ((val & 0x1) == 0) 258 #define NVLOG_FILTER_VALUE_IS_YES(val) (val & 0x1) 259 #define NVLOG_FILTER_PRINT_GET_VALUE(level, num) ((num >> (level*2)) & 0x3) 260 261 /** 262 * @brief Type representing a value of a given 16bit range. 263 */ 264 typedef struct _NVLOG_RANGE_16 265 { 266 NvU16 low; 267 NvU16 high; 268 NvU32 value; 269 } NVLOG_RANGE_16; 270 271 272 /** 273 * @brief Type representing a value of a given 32bit range. 274 */ 275 typedef struct _NVLOG_RANGE_32 276 { 277 NvU32 low; 278 NvU32 high; 279 NvU32 value; 280 } NVLOG_RANGE_32; 281 282 // 283 // Maximum number of files that have a filter assigned to them. 284 // 285 #define NVLOG_MAX_FILES 1 286 // 287 // Maximum number of line rules (both single line and range) allowed per file 288 // 289 #define NVLOG_FILELINE_FILTER_MAX_RANGES 1 290 291 /** 292 * @brief Internal type for NVLOG_FILELINE_FILTER. 293 * 294 * Contains filtering info for a single file. 295 */ 296 typedef struct _NVLOG_FILELINE_FILTER_FILEHASH 297 { 298 /** ID of the file (24bit MD5) */ 299 NvU32 fileId; 300 /** Number of elements in the array 'ranges' */ 301 NvU32 numElems; 302 /** Value to use if the given value isn't found in the range array */ 303 NvU32 defaultValue; 304 /** Array of ranges representing lines in the file */ 305 NVLOG_RANGE_16 ranges[NVLOG_FILELINE_FILTER_MAX_RANGES]; 306 } NVLOG_FILELINE_FILTER_FILEHASH; 307 308 /** 309 * @brief Filter that contains rules that depend on the file and line number. 310 */ 311 typedef struct _NVLOG_FILELINE_FILTER 312 { 313 /** Number of elements in the fileHash array */ 314 NvU32 numFiles; 315 /** Value to use if a given file isn't found */ 316 NvU32 defaultValue; 317 /** Array of file entries, ordered as a hash table */ 318 NVLOG_FILELINE_FILTER_FILEHASH fileHash[NVLOG_MAX_FILES]; 319 } NVLOG_FILELINE_FILTER; 320 321 /********************************/ 322 /********* Print Logger *********/ 323 /********************************/ 324 325 #define NVLOG_PRINT_LOGGER_VERSION 11 // v1.1 326 // Max buffers cannot be over 32. 327 #define NVLOG_PRINT_MAX_BUFFERS 8 328 329 #define NVLOG_PRINT_BUFFER_PRIMARY 1 330 #define NVLOG_PRINT_BUFFER_SECONDARY 2 331 #define NVLOG_PRINT_BUFFER_SYSTEMLOG 3 332 333 #define NVLOG_PRINT_DESC1_FILEID 23:0 334 #define NVLOG_PRINT_DESC1_GPUID 28:24 // 2^5 = 32 possible 335 #define NVLOG_PRINT_DESC1_MAGIC 31:29 336 #define NVLOG_PRINT_DESC1_MAGIC_VALUE 5 337 338 #define NVLOG_PRINT_DESC2_LINEID 15:0 339 #define NVLOG_PRINT_DESC2_GROUPID 17:16 340 #define NVLOG_PRINT_DESC2_GROUPID_RM 0 341 #define NVLOG_PRINT_DESC2_GROUPID_PMU 1 342 #define NVLOG_PRINT_DESC2_OPT_DATA_COUNT 24:18 // number of dwords 343 #define NVLOG_PRINT_DESC2_OPT_DATA_COUNT_MAX 0x7F 344 #define NVLOG_PRINT_DESC2_RESERVED 28:25 345 #define NVLOG_PRINT_DESC2_MAGIC 31:29 346 #define NVLOG_PRINT_DESC2_MAGIC_VALUE 6 347 348 #define NVLOG_UNKNOWN_GPU_INSTANCE 0x1f 349 350 #define NVLOG_PRINT_MODULE_FILTER_VALUE 1:0 351 #define NVLOG_PRINT_MODULE_FILTER_BUFFER 6:2 352 #define NVLOG_PRINT_MODULE_FILTER_ENABLED 7:7 353 354 // 355 // Regkey fields - These are copied directly from nvRmReg.h 356 // A copy is necessary as these might be needed on systems that don't 357 // have nvRmReg.h, such as DVS builds for NvWatch 358 // 359 #ifndef NV_REG_STR_RM_NVLOG 360 #define NV_REG_STR_RM_NVLOG "RMNvLog" 361 #define NV_REG_STR_RM_NVLOG_BUFFER_FLAGS 7:0 362 #define NV_REG_STR_RM_NVLOG_BUFFER_SIZE 23:8 363 #define NV_REG_STR_RM_NVLOG_BUFFER_SIZE_DEFAULT ((NVOS_IS_WINDOWS||NVOS_IS_MACINTOSH)?8:250) 364 #define NV_REG_STR_RM_NVLOG_BUFFER_SIZE_DISABLE 0 365 #define NV_REG_STR_RM_NVLOG_RUNTIME_LEVEL 28:25 366 #define NV_REG_STR_RM_NVLOG_TIMESTAMP 30:29 367 #define NV_REG_STR_RM_NVLOG_TIMESTAMP_NONE 0 368 #define NV_REG_STR_RM_NVLOG_TIMESTAMP_32 1 369 #define NV_REG_STR_RM_NVLOG_TIMESTAMP_64 2 370 #define NV_REG_STR_RM_NVLOG_TIMESTAMP_32_DIFF 3 371 #define NV_REG_STR_RM_NVLOG_INITED 31:31 372 #define NV_REG_STR_RM_NVLOG_INITED_NO 0 373 #define NV_REG_STR_RM_NVLOG_INITED_YES 1 374 #endif // NV_REG_STR_RM_NVLOG 375 376 377 // 378 // Arg types: 379 // 0: Special meaning. End of argument list. 380 // 1: d, u, x, X, i, o - Integer type 381 // 2: lld, llu, llx, llX, lli, llo - Long long integer type 382 // 3: s - string type (size is 0) 383 // 4: p - pointer type 384 // 5: c - char type 385 // 6: f, g, e, F, G, E - floating point type 386 // 7-14: Unused at the moment, default value is 0 387 // 15: Special meaning. Error value - unsupported type. 388 // 389 #define NVLOG_PRINT_MAX_ARG_TYPES 0x10 390 #define NVLOG_PRINT_ARG_TYPE_ARGLIST_END 0x0 391 #define NVLOG_PRINT_ARG_TYPE_INT 0x1 392 #define NVLOG_PRINT_ARG_TYPE_LONGLONG 0x2 393 #define NVLOG_PRINT_ARG_TYPE_STRING 0x3 394 #define NVLOG_PRINT_ARG_TYPE_POINTER 0x4 395 #define NVLOG_PRINT_ARG_TYPE_CHAR 0x5 396 #define NVLOG_PRINT_ARG_TYPE_FLOAT 0x6 397 #define NVLOG_PRINT_ARG_TYPE_ERROR 0xf 398 399 400 /** 401 * @brief Signature of the database required to decode the print logs 402 * 403 * The sig1-sig3 values are generated randomly at compile time. 404 */ 405 typedef struct _NVLOG_DB_SIGNATURE 406 { 407 NvU32 timestamp; 408 NvU32 sig1; 409 NvU32 sig2; 410 NvU32 sig3; 411 } NVLOG_DB_SIGNATURE; 412 413 /** 414 * @brief Filter that contains all rules used to filter DBG_PRINTF calls 415 */ 416 typedef struct _NVLOG_PRINT_FILTER 417 { 418 /** Same file:line filter is shared with the Regtrace system */ 419 NVLOG_FILELINE_FILTER *pFileLineFilter; 420 /** Filter based on debug levels. Uses NVLOG_FILTER_PRINT_LEVEL_* DRF's */ 421 NvU32 runtimePrintLevelFilter; 422 /** Filter based on debug modules. Uses NVLOG_PRINT_MODULE_FILTER_* DRF's */ 423 NvU8 runtimePrintModuleFilter[NVLOG_MAX_DBG_MODULES]; 424 } NVLOG_PRINT_FILTER; 425 426 427 /** 428 * @brief Enum representing all possible argument types to DBG_PRINTF 429 */ 430 typedef enum _NVLOG_ARGTYPE 431 { 432 NVLOG_ARGTYPE_NONE, 433 NVLOG_ARGTYPE_INT, 434 NVLOG_ARGTYPE_LONG_LONG_INT, 435 NVLOG_ARGTYPE_STRING, 436 NVLOG_ARGTYPE_POINTER, 437 NVLOG_ARGTYPE_FLOAT, 438 NVLOG_ARGTYPE__COUNT 439 } NVLOG_ARGTYPE; 440 441 // Default flags for NvLog registry, used for single-buffer option or the read fails 442 #ifndef NVLOG_DEFAULT_FLAGS 443 #define NVLOG_DEFAULT_FLAGS \ 444 ( \ 445 DRF_NUM(_REG_STR_RM, _NVLOG, _BUFFER_FLAGS, \ 446 ( \ 447 DRF_DEF(LOG, _BUFFER_FLAGS, _DISABLED, _NO) | \ 448 DRF_DEF(LOG, _BUFFER_FLAGS, _TYPE, _RING) | \ 449 DRF_DEF(LOG, _BUFFER_FLAGS, _EXPANDABLE, _NO) | \ 450 DRF_DEF(LOG, _BUFFER_FLAGS, _NONPAGED, _YES) | \ 451 DRF_DEF(LOG, _BUFFER_FLAGS, _LOCKING, _STATE) | \ 452 DRF_DEF(LOG, _BUFFER_FLAGS, _OCA, _YES) \ 453 )) | \ 454 DRF_DEF(_REG_STR_RM, _NVLOG, _BUFFER_SIZE, _DEFAULT) | \ 455 DRF_NUM(_REG_STR_RM, _NVLOG, _RUNTIME_LEVEL, 0) | \ 456 DRF_DEF(_REG_STR_RM, _NVLOG, _TIMESTAMP, _32) | \ 457 DRF_DEF(_REG_STR_RM, _NVLOG, _INITED, _YES) \ 458 ) 459 #endif // NVLOG_DEFAULT_FLAGS 460 461 /** 462 * @brief General info about the NvLog Print system 463 */ 464 typedef struct _NVLOG_PRINT_LOGGER 465 { 466 /** NvLog print logger version */ 467 NvU32 version; 468 /** Runtime argument sizes (16 different arglist values) */ 469 NvU8 runtimeSizes[NVLOG_PRINT_MAX_ARG_TYPES]; 470 /** Database signature for decoding */ 471 NVLOG_DB_SIGNATURE signature; 472 /** Filter buffer for print statements */ 473 NVLOG_PRINT_FILTER filter; 474 /** Flags for all NvLog print buffers */ 475 NvU32 flags; 476 /** Buffer indices for all nvlog buffers. buffers[1] is default. */ 477 NvU32 buffers[NVLOG_PRINT_MAX_BUFFERS]; 478 /** Initialized flag, set to true after nvlogPrintInit has executed */ 479 NvBool initialized; 480 /** Paused flag, set to true after nvlogPrintInit has executed */ 481 NvBool paused; 482 } NVLOG_PRINT_LOGGER; 483 extern NVLOG_PRINT_LOGGER NvLogPrintLogger; 484 485 #define NVLOG_PRINT_BUFFER_TAG(_i) NvU32_BUILD('t','r','p','0' + (_i)) 486 487 /********************************/ 488 /********** Regtrace **********/ 489 /********************************/ 490 491 #define NVLOG_REGTRACE_LOGGER_VERSION 10 // v1.0 492 #define NVLOG_REGTRACE_MAX_BUFFERS 4 493 494 #define NVLOG_REGTRACE_READ 0 495 #define NVLOG_REGTRACE_WRITE 1 496 497 #define NVLOG_REGTRACE_DESC1_FILEID NVLOG_PRINT_DESC1_FILEID 498 #define NVLOG_REGTRACE_DESC1_GPUID NVLOG_PRINT_DESC1_GPUID 499 #define NVLOG_REGTRACE_DESC1_MAGIC NVLOG_PRINT_DESC1_MAGIC 500 #define NVLOG_REGTRACE_DESC1_MAGIC_VALUE (NVLOG_PRINT_DESC1_MAGIC_VALUE-1) 501 502 #define NVLOG_REGTRACE_DESC2_LINEID 15:0 503 #define NVLOG_REGTRACE_DESC2_READWRITE 16:16 504 #define NVLOG_REGTRACE_DESC2_READWRITE_READ NVLOG_REGTRACE_READ 505 #define NVLOG_REGTRACE_DESC2_READWRITE_WRITE NVLOG_REGTRACE_WRITE 506 #define NVLOG_REGTRACE_DESC2_REGSIZE 18:17 507 #define NVLOG_REGTRACE_DESC2_REGSIZE_8 0 508 #define NVLOG_REGTRACE_DESC2_REGSIZE_16 1 509 #define NVLOG_REGTRACE_DESC2_REGSIZE_32 2 510 #define NVLOG_REGTRACE_DESC2_REGSIZE_64 3 511 #define NVLOG_REGTRACE_DESC2_THREADID 28:19 512 #define NVLOG_REGTRACE_DESC2_MAGIC 31:29 513 #define NVLOG_REGTRACE_DESC2_MAGIC_VALUE 3 514 515 /** 516 * @brief Single entry in an NvLog Regtrace buffer. 517 */ 518 typedef struct _NVLOG_REGTRACE_RECORD 519 { 520 /** Uses NVLOG_REGTRACE_DESC1_* DRF's */ 521 NvU32 desc1; 522 /** Uses NVLOG_REGTRACE_DESC1_* DRF's */ 523 NvU32 desc2; 524 /** Address of the register being accessed */ 525 NvU32 address; 526 /** Value that was read/written */ 527 NvU32 value; 528 } NVLOG_REGTRACE_RECORD; 529 530 531 532 #define NVLOG_REGTRACE_FILTER_MAX_RANGES 256 533 534 // Regtrace shares the file:line filter with print 535 536 537 /** 538 * @brief Filter that contains all rules used to filter register access logging 539 */ 540 typedef struct _NVLOG_REGTRACE_FILTER 541 { 542 /** Number of elements in the 'ranges' array */ 543 NvU32 numRanges; 544 /** File:line based filter. Shared with NvLog print system */ 545 NVLOG_FILELINE_FILTER *pFileLineFilter; 546 /** Range array for filtering based on register addresses */ 547 NVLOG_RANGE_32 ranges[NVLOG_REGTRACE_FILTER_MAX_RANGES]; 548 } NVLOG_REGTRACE_FILTER; 549 550 /** 551 * @brief General info about the NvLog Regtrace system 552 */ 553 typedef struct _NVLOG_REGTRACE_LOGGER 554 { 555 /** NvLog regtrace logger version */ 556 NvU32 version; 557 /** Filter buffer for regtrace statements */ 558 NVLOG_REGTRACE_FILTER filter; 559 /** Buffer indices for all NvLog buffers. First element is default buffer */ 560 NvU32 buffers[NVLOG_REGTRACE_MAX_BUFFERS]; 561 } NVLOG_REGTRACE_LOGGER; 562 563 #endif // _NVLOG_DEFS_H_ 564