OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2007-2009 NVIDIA Corporation. |
| 3 * All rights reserved. |
| 4 * |
| 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: |
| 7 * |
| 8 * Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. |
| 10 * |
| 11 * Redistributions in binary form must reproduce the above copyright notice, |
| 12 * this list of conditions and the following disclaimer in the documentation |
| 13 * and/or other materials provided with the distribution. |
| 14 * |
| 15 * Neither the name of the NVIDIA Corporation nor the names of its contributors |
| 16 * may be used to endorse or promote products derived from this software |
| 17 * without specific prior written permission. |
| 18 * |
| 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 * POSSIBILITY OF SUCH DAMAGE. |
| 30 * |
| 31 */ |
| 32 |
| 33 #ifndef INCLUDED_NVRM_RMCTRACE_H |
| 34 #define INCLUDED_NVRM_RMCTRACE_H |
| 35 |
| 36 #include "nvcommon.h" |
| 37 #include "nvos.h" |
| 38 #include "nvrm_init.h" |
| 39 |
| 40 /** |
| 41 * RMC is a file format for capturing accesses to hardware, both memory |
| 42 * and register, that may be played back against a simulator. Drivers |
| 43 * are expected to emit RMC tracing if RMC tracing is enabled. |
| 44 * |
| 45 * The RM will already have an RMC file open before any drivers are expected |
| 46 * to access it, so it is not necessary for NvRmRmcOpen or Close to be called |
| 47 * by anyone except the RM itself (but drivers may want to if capturing a |
| 48 * subset of commands is useful). |
| 49 */ |
| 50 |
| 51 #ifdef __cplusplus |
| 52 extern "C" |
| 53 { |
| 54 #endif /* __cplusplus */ |
| 55 |
| 56 #if !defined(NV_OAL) |
| 57 #define NV_OAL 0 |
| 58 #endif |
| 59 |
| 60 // FIXME: better rmc compile time macros |
| 61 #if !defined(NV_DEF_RMC_TRACE) |
| 62 #if NV_DEBUG && !NV_OAL |
| 63 #define NV_DEF_RMC_TRACE 1 |
| 64 #else |
| 65 #define NV_DEF_RMC_TRACE 0 |
| 66 #endif |
| 67 #endif |
| 68 |
| 69 /** |
| 70 * exposed structure for RMC files. |
| 71 */ |
| 72 typedef struct NvRmRMCFile_t |
| 73 { |
| 74 NvOsFileHandle file; |
| 75 NvBool enable; /* enable bit for writes */ |
| 76 } NvRmRmcFile; |
| 77 |
| 78 /** |
| 79 * opens the an RMC file. |
| 80 * |
| 81 * @param name The name of the rmc file |
| 82 * @param rmc Out param - the opened rmc file (if successful) |
| 83 * |
| 84 * NvOsFile* operatations should not be used directly since RMC commands |
| 85 * or comments may be emited to the file on open/close/etc. |
| 86 */ |
| 87 NvError |
| 88 NvRmRmcOpen( const char *name, NvRmRmcFile *rmc ); |
| 89 |
| 90 /** |
| 91 * closes an RMC file. |
| 92 * |
| 93 * @param rmc The rmc file to close. |
| 94 */ |
| 95 void |
| 96 NvRmRmcClose( NvRmRmcFile *rmc ); |
| 97 |
| 98 /** |
| 99 * emits a string to the RMC file. |
| 100 * |
| 101 * @param file The RMC file |
| 102 * @param format Printf style argument format string |
| 103 * |
| 104 * NvRmRmcOpen must be called before this function. |
| 105 * |
| 106 * This function should be called via a macro so that it may be compiled out. |
| 107 * Note that double parens will be needed: |
| 108 * |
| 109 * NVRM_RMC_TRACE(( file, "# filling memory with stuff\n" )); |
| 110 */ |
| 111 void |
| 112 NvRmRmcTrace( NvRmRmcFile *rmc, const char *format, ... ); |
| 113 |
| 114 /** |
| 115 * retrieves the RM's global RMC file. |
| 116 * |
| 117 * @param hDevice The RM instance |
| 118 * @param file Output param: the RMC file |
| 119 */ |
| 120 NvError |
| 121 NvRmGetRmcFile( NvRmDeviceHandle hDevice, NvRmRmcFile **file ); |
| 122 |
| 123 #if NV_DEF_RMC_TRACE |
| 124 #define NVRM_RMC_TRACE(a) NvRmRmcTrace a |
| 125 /** |
| 126 * enable or disable RMC tracing at runtime. |
| 127 * |
| 128 * @param file The RMC file |
| 129 * @param enable Either enable or disable rmc tracing |
| 130 */ |
| 131 #define NVRM_RMC_ENABLE(f, e) \ |
| 132 ((f)->enable = (e)) |
| 133 |
| 134 #define NVRM_RMC_IS_ENABLED(f) \ |
| 135 ((f)->enable != 0) |
| 136 |
| 137 #else |
| 138 #define NVRM_RMC_TRACE(a) (void)0 |
| 139 #define NVRM_RMC_ENABLE(f,e) (void)0 |
| 140 #define NVRM_RMC_IS_ENABLED(f) (void)0 |
| 141 #endif |
| 142 |
| 143 #ifdef __cplusplus |
| 144 } |
| 145 #endif /* __cplusplus */ |
| 146 |
| 147 #endif /* NVRM_RMCTRACE_H */ |
OLD | NEW |