• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __NVHW_QMD_H__
2 #define __NVHW_QMD_H__
3 #include <stdio.h>
4 #include <stdint.h>
5 #include "util/u_debug.h"
6 #include "drf.h"
7 
8 #define NVQMD_ENUM_1(X,drf,v0)                                                 \
9    [drf##_##v0] = #v0
10 #define NVQMD_ENUM_2(X,drf,v0,v1)                                              \
11    [drf##_##v0] = #v0,                                                         \
12    [drf##_##v1] = #v1
13 #define NVQMD_ENUM_3(X,drf,v0,v1,v2)                                           \
14    [drf##_##v0] = #v0,                                                         \
15    [drf##_##v1] = #v1,                                                         \
16    [drf##_##v2] = #v2
17 #define NVQMD_ENUM_8(X,drf,v0,v1,v2,v3,v4,v5,v6,v7)                            \
18    [drf##_##v0] = #v0,                                                         \
19    [drf##_##v1] = #v1,                                                         \
20    [drf##_##v2] = #v2,                                                         \
21    [drf##_##v3] = #v3,                                                         \
22    [drf##_##v4] = #v4,                                                         \
23    [drf##_##v5] = #v5,                                                         \
24    [drf##_##v6] = #v6,                                                         \
25    [drf##_##v7] = #v7
26 
27 #define NVQMD_ENUM_(X,_1,_2,_3,_4,_5,_6,_7,_8,_9,IMPL,...) IMPL
28 #define NVQMD_ENUM(A...) NVQMD_ENUM_(X, ##A, NVQMD_ENUM_8, NVQMD_ENUM_7,       \
29                                              NVQMD_ENUM_6, NVQMD_ENUM_5,       \
30                                              NVQMD_ENUM_4, NVQMD_ENUM_3,       \
31                                              NVQMD_ENUM_2, NVQMD_ENUM_1)(X, ##A)
32 
33 #define NVQMD_VAL_N(X,d,r,p,f,o) do {                                          \
34    uint32_t val = NVVAL_MW_GET_X((p), d##_##r##_##f);                          \
35    debug_printf("   %-36s: "o"\n", #f, val);                                   \
36 } while(0)
37 #define NVQMD_VAL_I(X,d,r,p,f,i,o) do {                                        \
38    uint32_t val = NVVAL_MW_GET_X((p), d##_##r##_##f(i));                       \
39    char name[80];                                                              \
40    snprintf(name, sizeof(name), "%s(%d)", #f, i);                              \
41    debug_printf("   %-36s: "o"\n", name, val);                                 \
42 } while(0)
43 #define NVQMD_VAL_(X,_1,_2,_3,_4,_5,_6,IMPL,...) IMPL
44 #define NVQMD_VAL(A...) NVQMD_VAL_(X, ##A, NVQMD_VAL_I, NVQMD_VAL_N)(X, ##A)
45 
46 #define NVQMD_DEF(d,r,p,f,e...) do {                                           \
47    static const char *ev[] = { NVQMD_ENUM(d##_##r##_##f,##e) };                \
48    uint32_t val = NVVAL_MW_GET((p), d, r, f);                                  \
49    if (val < ARRAY_SIZE(ev) && ev[val])                                        \
50       debug_printf("   %-36s: %s\n", #f, ev[val]);                             \
51    else                                                                        \
52       debug_printf("   %-36s: UNKNOWN 0x%x\n", #f, val);                       \
53 } while(0)
54 #define NVQMD_IDX(d,r,p,f,i,e...) do {                                         \
55    static const char *ev[] = { NVQMD_ENUM(d##_##r##_##f,##e) };                \
56    char name[80];                                                              \
57    snprintf(name, sizeof(name), "%s(%d)", #f, i);                              \
58    uint32_t val = NVVAL_MW_GET((p), d, r, f, i);                               \
59    if (val < ARRAY_SIZE(ev) && ev[val])                                        \
60       debug_printf("   %-36s: %s\n", name, ev[val]);                           \
61    else                                                                        \
62       debug_printf("   %-36s: UNKNOWN 0x%x\n", name, val);                     \
63 } while(0)
64 
65 void NVA0C0QmdDump_V00_06(uint32_t *);
66 void NVC0C0QmdDump_V02_01(uint32_t *);
67 void NVC3C0QmdDump_V02_02(uint32_t *);
68 #endif
69