File: cm_debug.h

package info (click to toggle)
intel-media-driver 18.4.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 77,144 kB
  • sloc: cpp: 784,288; ansic: 95,944; asm: 42,125; python: 353; sh: 156; makefile: 15
file content (224 lines) | stat: -rw-r--r-- 9,083 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
* Copyright (c) 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file      cm_debug.h 
//! \brief     Contains CM debug definitions 
//!

#ifndef __CM_DEBUG_H__
#define __CM_DEBUG_H__

#include "cm_common.h"
#include "mos_utilities.h"
#include "mos_util_debug.h"

//*-----------------------------------------------------------------------------
//| Assert Definitions
//*-----------------------------------------------------------------------------
#define CM_ASSERT(expr) \
    MOS_ASSERT(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_SELF, expr)
#define CM_ASSERT_DDI(expr) \
    MOS_ASSERT(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_DDI, expr)
#define CM_ASSERT_PUBLIC(expr) \
    MOS_ASSERT(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_PUBLIC, expr)
#define CM_ASSERT_RENDERHAL(expr) \
    MOS_ASSERT(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, expr)

//*-----------------------------------------------------------------------------
//| Message Print Definitions
//*-----------------------------------------------------------------------------
#define CM_ASSERTMESSAGE(msg, ...) \
    MOS_ASSERTMESSAGE(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_SELF, msg, ##__VA_ARGS__)
#define CM_ASSERTMESSAGE_DDI(msg, ...) \
    MOS_ASSERTMESSAGE(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_DDI, msg, ##__VA_ARGS__)
#define CM_ASSERTMESSAGE_PUBLIC(msg, ...) \
    MOS_ASSERTMESSAGE(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_PUBLIC, msg, ##__VA_ARGS__)
#define CM_ASSERTMESSAGE_RENDERHAL(msg, ...) \
    MOS_ASSERTMESSAGE(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, msg, ##__VA_ARGS__)
    
#define CM_NORMALMESSAGE(msg, ...) \
    MOS_NORMALMESSAGE(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_SELF, msg, ##__VA_ARGS__)   
#define CM_NORMALMESSAGE_DDI(msg, ...) \
    MOS_NORMALMESSAGE(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_DDI, msg, ##__VA_ARGS__)
#define CM_NORMALMESSAGE_PUBLIC(msg, ...) \
    MOS_NORMALMESSAGE(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_PUBLIC, msg, ##__VA_ARGS__)   
#define CM_NORMALMESSAGE_RENDERHAL(msg, ...) \
    MOS_NORMALMESSAGE(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL, msg, ##__VA_ARGS__)   
   
#define CM_FUNCTION_ENTER \
    MOS_FUNCTION_ENTER(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_SELF)
#define CM_FUNCTION_ENTER_DDI \
    MOS_FUNCTION_ENTER(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_DDI)
#define CM_FUNCTION_ENTER_PUBLIC \
    MOS_FUNCTION_ENTER(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_PUBLIC)
#define CM_FUNCTION_ENTER_RENDERHAL \
    MOS_FUNCTION_ENTER(MOS_COMPONENT_CM, MOS_CM_SUBCOMP_RENDERHAL)


//*-----------------------------------------------------------------------------
//| Private Definitions (not suggest to use in other file)
//*-----------------------------------------------------------------------------
#define _CHECK_AND_GOTO_FINISH(cond, ret, retval, msg, ...) \
{ \
    if (cond) \
    { \
        ret = retval; \
        CM_ASSERTMESSAGE(msg, ##__VA_ARGS__); \
        goto finish;\
    } \
}

#define _CHECK_AND_RETURN(cond, retval, msg, ...) \
{ \
    if (cond) \
    {\
        CM_ASSERTMESSAGE(msg, ##__VA_ARGS__); \
        return retval;\
    }\
}

#define _CHECK_AND_RETURN_VOID(cond, msg, ...) \
{ \
    if(cond) \
    { \
        CM_ASSERTMESSAGE(msg, ##__VA_ARGS__); \
        return; \
    } \
}

#define _MOSSTATUS2CM(mosstatus, cmstatus) \
{ \
    switch((MOS_STATUS)mosstatus) { \
        case MOS_STATUS_SUCCESS: \
            cmstatus = CM_SUCCESS; \
            break; \
        case MOS_STATUS_NULL_POINTER: \
            cmstatus = CM_NULL_POINTER; \
            break;  \
        case MOS_STATUS_EXCEED_MAX_BB_SIZE: \
            cmstatus = CM_TOO_MUCH_THREADS; \
            break; \
        default: \
            cmstatus = (CM_RETURN_CODE)(0 - mosstatus + CM_MOS_STATUS_CONVERTED_CODE_OFFSET); \
            break; \
    } \
}

//*-----------------------------------------------------------------------------
//| Public Check Definitions
//*-----------------------------------------------------------------------------
// Check general condition.
#define CM_CHK_COND_GOTOFINISH(cond, retval, msg, ...) \
    _CHECK_AND_GOTO_FINISH(cond, eStatus, retval, msg, ##__VA_ARGS__)
#define CM_CHK_COND_RETURN(cond, retval, msg, ...) \
    _CHECK_AND_RETURN(cond, retval, msg, ##__VA_ARGS__)

// Check nullptr then goto finish.
#define CM_CHK_NULL_GOTOFINISH_MOSERROR(ptr) \
    _CHECK_AND_GOTO_FINISH((ptr == nullptr), eStatus, MOS_STATUS_NULL_POINTER, "Null pointer found!")
#define CM_CHK_NULL_GOTOFINISH_CMERROR(ptr) \
    _CHECK_AND_GOTO_FINISH((ptr == nullptr), hr, CM_NULL_POINTER, "Null pointer found!")
#define CM_CHK_NULL_GOTOFINISH(ptr, retval) \
    _CHECK_AND_GOTO_FINISH((ptr == nullptr), hr, retval, "Null pointer found!")
#define CM_CHK_NULL_GOTOFINISH_WITH_MSG(ptr, retval, msg, ...) \
    _CHECK_AND_GOTO_FINISH((ptr == nullptr), hr, retval, msg, ##__VA_ARGS__);

// Check nullptr then return.
#define CM_CHK_NULL_RETURN_MOSERROR(ptr) \
    _CHECK_AND_RETURN((ptr == nullptr), MOS_STATUS_NULL_POINTER, "Null pointer found!");
#define CM_CHK_NULL_RETURN_CMERROR(ptr) \
    _CHECK_AND_RETURN((ptr == nullptr), CM_NULL_POINTER, "Null pointer found!");
#define CM_CHK_NULL_RETURN(ptr, retval) \
    _CHECK_AND_RETURN((ptr == nullptr), retval, "Null pointer found!");
#define CM_CHK_NULL_RETURN_WITH_MSG(ptr, retval, msg, ...) \
    _CHECK_AND_RETURN((ptr == nullptr), retval, msg, ##__VA_ARGS__);
#define CM_CHK_NULL_RETURN_VOID(ptr) \
    _CHECK_AND_RETURN_VOID((ptr == nullptr), "Null pointer found!");

// Check return status.
#define CM_CHK_MOSSTATUS_GOTOFINISH(stmt) \
{ \
    eStatus = (MOS_STATUS)(stmt); \
    _CHECK_AND_GOTO_FINISH((eStatus != MOS_STATUS_SUCCESS), eStatus, eStatus , "MOS return error [%d]", eStatus); \
}
#define CM_CHK_MOSSTATUS_RETURN(stmt) \
{ \
    MOS_STATUS _tmp = (MOS_STATUS)(stmt); \
    _CHECK_AND_RETURN((_tmp != MOS_STATUS_SUCCESS), _tmp, "MOS return error [%d]", _tmp) \
}
#define CM_CHK_CMSTATUS_GOTOFINISH(stmt) \
{ \
    hr = (CM_RETURN_CODE)(stmt); \
    _CHECK_AND_GOTO_FINISH((hr != CM_SUCCESS), hr, hr, "CM return error [%d]", hr); \
}
#define CM_CHK_CMSTATUS_RETURN(stmt) \
{ \
    CM_RETURN_CODE _tmp = (CM_RETURN_CODE)(stmt); \
    _CHECK_AND_RETURN((_tmp != CM_SUCCESS), _tmp, "CM return error [%d]", _tmp) \
} 
#define CM_CHK_CMSTATUS_GOTOFINISH_WITH_MSG(stmt, msg, ...) \
{ \
    hr = (CM_RETURN_CODE)(stmt); \
    _CHECK_AND_GOTO_FINISH((hr != CM_SUCCESS), hr, hr, msg,  ##__VA_ARGS__); \
}
#define CM_CHK_CMSTATUS_RETURN_WITH_MSG(stmt, msg, ...) \
{ \
    CM_RETURN_CODE _tmp = (CM_RETURN_CODE)(stmt); \
    _CHECK_AND_RETURN((_tmp != CM_SUCCESS), _tmp, msg,  ##__VA_ARGS__) \
}
#define CM_CHK_HRESULT_GOTOFINISH_MOSERROR(stmt) \
{ \
    eStatus = (MOS_STATUS)OsResultToMOS_Status(stmt); \
    _CHECK_AND_GOTO_FINISH((eStatus != MOS_STATUS_SUCCESS), eStatus, eStatus, "hr check failed [%d]", eStatus); \
}
#define CM_CHK_MOSSTATUS_GOTOFINISH_CMERROR(stmt) \
{ \
    MOS_STATUS hr_mos = (MOS_STATUS)(stmt); \
    _MOSSTATUS2CM(hr_mos, hr); \
    _CHECK_AND_GOTO_FINISH((hr_mos != MOS_STATUS_SUCCESS), hr, hr, "MOS return error [%d]", hr_mos); \
}

/*===================== EU Debugger related stuff ===========================*/

bool RequestSipBinary(PLATFORM platform,
                      uint32_t bti,
                      const uint8_t *& sip,
                      uint32_t& sipSize,
                      uint32_t& resSize);

/*===================== end EU Debugger related stuff =======================*/
uint32_t GetLogFileLocation(const char *filename, char fileNamePrefix[]);
int32_t GetDumpCounter(const char *pValueName);
int32_t RecordDumpCounter(int32_t count, uint32_t ValueID);

int32_t GetCommandBufferDumpCounter(const char *pValueName);
int32_t RecordCommandBufferDumpCounter(int32_t count, uint32_t ValueID);

int32_t GetSurfaceStateDumpCounter(const char *pValueName);
int32_t RecordSurfaceStateDumpCounter(int32_t count, uint32_t ValueID);

int32_t GetInterfaceDescriptorDataDumpCounter(const char *pValueName);
int32_t RecordInterfaceDescriptorDataDumpCounter(int32_t count, uint32_t ValueID);

uint32_t GetCommandBufferHeaderDWords(PMOS_INTERFACE osInterface);

#endif // __CM_DEBUG_H__