18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2019 Red Hat Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci */
228c2ecf20Sopenharmony_ci#ifndef __NVHW_DRF_H__
238c2ecf20Sopenharmony_ci#define __NVHW_DRF_H__
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/* Helpers common to all DRF accessors. */
268c2ecf20Sopenharmony_ci#define DRF_LO(drf)    (0 ? drf)
278c2ecf20Sopenharmony_ci#define DRF_HI(drf)    (1 ? drf)
288c2ecf20Sopenharmony_ci#define DRF_BITS(drf)  (DRF_HI(drf) - DRF_LO(drf) + 1)
298c2ecf20Sopenharmony_ci#define DRF_MASK(drf)  (~0ULL >> (64 - DRF_BITS(drf)))
308c2ecf20Sopenharmony_ci#define DRF_SMASK(drf) (DRF_MASK(drf) << DRF_LO(drf))
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* Helpers for DRF-MW accessors. */
338c2ecf20Sopenharmony_ci#define DRF_MX_MW(drf)      drf
348c2ecf20Sopenharmony_ci#define DRF_MX(drf)         DRF_MX_##drf
358c2ecf20Sopenharmony_ci#define DRF_MW(drf)         DRF_MX(drf)
368c2ecf20Sopenharmony_ci#define DRF_MW_SPANS(o,drf) (DRF_LW_IDX((o),drf) != DRF_HW_IDX((o),drf))
378c2ecf20Sopenharmony_ci#define DRF_MW_SIZE(o)      (sizeof((o)[0]) * 8)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define DRF_LW_IDX(o,drf)   (DRF_LO(DRF_MW(drf)) / DRF_MW_SIZE(o))
408c2ecf20Sopenharmony_ci#define DRF_LW_LO(o,drf)    (DRF_LO(DRF_MW(drf)) % DRF_MW_SIZE(o))
418c2ecf20Sopenharmony_ci#define DRF_LW_HI(o,drf)    (DRF_MW_SPANS((o),drf) ? (DRF_MW_SIZE(o) - 1) : DRF_HW_HI((o),drf))
428c2ecf20Sopenharmony_ci#define DRF_LW_BITS(o,drf)  (DRF_LW_HI((o),drf) - DRF_LW_LO((o),drf) + 1)
438c2ecf20Sopenharmony_ci#define DRF_LW_MASK(o,drf)  (~0ULL >> (64 - DRF_LW_BITS((o),drf)))
448c2ecf20Sopenharmony_ci#define DRF_LW_SMASK(o,drf) (DRF_LW_MASK((o),drf) << DRF_LW_LO((o),drf))
458c2ecf20Sopenharmony_ci#define DRF_LW_GET(o,drf)   (((o)[DRF_LW_IDX((o),drf)] >> DRF_LW_LO((o),drf)) & DRF_LW_MASK((o),drf))
468c2ecf20Sopenharmony_ci#define DRF_LW_VAL(o,drf,v) (((v) & DRF_LW_MASK((o),drf)) << DRF_LW_LO((o),drf))
478c2ecf20Sopenharmony_ci#define DRF_LW_CLR(o,drf)   ((o)[DRF_LW_IDX((o),drf)] & ~DRF_LW_SMASK((o),drf))
488c2ecf20Sopenharmony_ci#define DRF_LW_SET(o,drf,v) (DRF_LW_CLR((o),drf) | DRF_LW_VAL((o),drf,(v)))
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define DRF_HW_IDX(o,drf)   (DRF_HI(DRF_MW(drf)) / DRF_MW_SIZE(o))
518c2ecf20Sopenharmony_ci#define DRF_HW_LO(o,drf)    0
528c2ecf20Sopenharmony_ci#define DRF_HW_HI(o,drf)    (DRF_HI(DRF_MW(drf)) % DRF_MW_SIZE(o))
538c2ecf20Sopenharmony_ci#define DRF_HW_BITS(o,drf)  (DRF_HW_HI((o),drf) - DRF_HW_LO((o),drf) + 1)
548c2ecf20Sopenharmony_ci#define DRF_HW_MASK(o,drf)  (~0ULL >> (64 - DRF_HW_BITS((o),drf)))
558c2ecf20Sopenharmony_ci#define DRF_HW_SMASK(o,drf) (DRF_HW_MASK((o),drf) << DRF_HW_LO((o),drf))
568c2ecf20Sopenharmony_ci#define DRF_HW_GET(o,drf)   ((o)[DRF_HW_IDX(o,drf)] & DRF_HW_SMASK((o),drf))
578c2ecf20Sopenharmony_ci#define DRF_HW_VAL(o,drf,v) (((long long)(v) >> DRF_LW_BITS((o),drf)) & DRF_HW_SMASK((o),drf))
588c2ecf20Sopenharmony_ci#define DRF_HW_CLR(o,drf)   ((o)[DRF_HW_IDX((o),drf)] & ~DRF_HW_SMASK((o),drf))
598c2ecf20Sopenharmony_ci#define DRF_HW_SET(o,drf,v) (DRF_HW_CLR((o),drf) | DRF_HW_VAL((o),drf,(v)))
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* DRF accessors. */
628c2ecf20Sopenharmony_ci#define NVVAL_X(drf,v) (((v) & DRF_MASK(drf)) << DRF_LO(drf))
638c2ecf20Sopenharmony_ci#define NVVAL_N(X,d,r,f,  v) NVVAL_X(d##_##r##_##f, (v))
648c2ecf20Sopenharmony_ci#define NVVAL_I(X,d,r,f,i,v) NVVAL_X(d##_##r##_##f(i), (v))
658c2ecf20Sopenharmony_ci#define NVVAL_(X,_1,_2,_3,_4,_5,IMPL,...) IMPL
668c2ecf20Sopenharmony_ci#define NVVAL(A...) NVVAL_(X, ##A, NVVAL_I, NVVAL_N)(X, ##A)
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define NVDEF_N(X,d,r,f,  v) NVVAL_X(d##_##r##_##f, d##_##r##_##f##_##v)
698c2ecf20Sopenharmony_ci#define NVDEF_I(X,d,r,f,i,v) NVVAL_X(d##_##r##_##f(i), d##_##r##_##f##_##v)
708c2ecf20Sopenharmony_ci#define NVDEF_(X,_1,_2,_3,_4,_5,IMPL,...) IMPL
718c2ecf20Sopenharmony_ci#define NVDEF(A...) NVDEF_(X, ##A, NVDEF_I, NVDEF_N)(X, ##A)
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define NVVAL_GET_X(o,drf) (((o) >> DRF_LO(drf)) & DRF_MASK(drf))
748c2ecf20Sopenharmony_ci#define NVVAL_GET_N(X,o,d,r,f  ) NVVAL_GET_X(o, d##_##r##_##f)
758c2ecf20Sopenharmony_ci#define NVVAL_GET_I(X,o,d,r,f,i) NVVAL_GET_X(o, d##_##r##_##f(i))
768c2ecf20Sopenharmony_ci#define NVVAL_GET_(X,_1,_2,_3,_4,_5,IMPL,...) IMPL
778c2ecf20Sopenharmony_ci#define NVVAL_GET(A...) NVVAL_GET_(X, ##A, NVVAL_GET_I, NVVAL_GET_N)(X, ##A)
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#define NVVAL_TEST_X(o,drf,cmp,drfv) (NVVAL_GET_X((o), drf) cmp drfv)
808c2ecf20Sopenharmony_ci#define NVVAL_TEST_N(X,o,d,r,f,  cmp,v) NVVAL_TEST_X(o, d##_##r##_##f   , cmp, (v))
818c2ecf20Sopenharmony_ci#define NVVAL_TEST_I(X,o,d,r,f,i,cmp,v) NVVAL_TEST_X(o, d##_##r##_##f(i), cmp, (v))
828c2ecf20Sopenharmony_ci#define NVVAL_TEST_(X,_1,_2,_3,_4,_5,_6,_7,IMPL,...) IMPL
838c2ecf20Sopenharmony_ci#define NVVAL_TEST(A...) NVVAL_TEST_(X, ##A, NVVAL_TEST_I, NVVAL_TEST_N)(X, ##A)
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define NVDEF_TEST_N(X,o,d,r,f,  cmp,v) NVVAL_TEST_X(o, d##_##r##_##f   , cmp, d##_##r##_##f##_##v)
868c2ecf20Sopenharmony_ci#define NVDEF_TEST_I(X,o,d,r,f,i,cmp,v) NVVAL_TEST_X(o, d##_##r##_##f(i), cmp, d##_##r##_##f##_##v)
878c2ecf20Sopenharmony_ci#define NVDEF_TEST_(X,_1,_2,_3,_4,_5,_6,_7,IMPL,...) IMPL
888c2ecf20Sopenharmony_ci#define NVDEF_TEST(A...) NVDEF_TEST_(X, ##A, NVDEF_TEST_I, NVDEF_TEST_N)(X, ##A)
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci#define NVVAL_SET_X(o,drf,v) (((o) & ~DRF_SMASK(drf)) | NVVAL_X(drf, (v)))
918c2ecf20Sopenharmony_ci#define NVVAL_SET_N(X,o,d,r,f,  v) NVVAL_SET_X(o, d##_##r##_##f, (v))
928c2ecf20Sopenharmony_ci#define NVVAL_SET_I(X,o,d,r,f,i,v) NVVAL_SET_X(o, d##_##r##_##f(i), (v))
938c2ecf20Sopenharmony_ci#define NVVAL_SET_(X,_1,_2,_3,_4,_5,_6,IMPL,...) IMPL
948c2ecf20Sopenharmony_ci#define NVVAL_SET(A...) NVVAL_SET_(X, ##A, NVVAL_SET_I, NVVAL_SET_N)(X, ##A)
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci#define NVDEF_SET_N(X,o,d,r,f,  v) NVVAL_SET_X(o, d##_##r##_##f,    d##_##r##_##f##_##v)
978c2ecf20Sopenharmony_ci#define NVDEF_SET_I(X,o,d,r,f,i,v) NVVAL_SET_X(o, d##_##r##_##f(i), d##_##r##_##f##_##v)
988c2ecf20Sopenharmony_ci#define NVDEF_SET_(X,_1,_2,_3,_4,_5,_6,IMPL,...) IMPL
998c2ecf20Sopenharmony_ci#define NVDEF_SET(A...) NVDEF_SET_(X, ##A, NVDEF_SET_I, NVDEF_SET_N)(X, ##A)
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci/* DRF-MW accessors. */
1028c2ecf20Sopenharmony_ci#define NVVAL_MW_GET_X(o,drf)                                                       \
1038c2ecf20Sopenharmony_ci	((DRF_MW_SPANS((o),drf) ?                                                   \
1048c2ecf20Sopenharmony_ci	  (DRF_HW_GET((o),drf) << DRF_LW_BITS((o),drf)) : 0) | DRF_LW_GET((o),drf))
1058c2ecf20Sopenharmony_ci#define NVVAL_MW_GET_N(X,o,d,r,f  ) NVVAL_MW_GET_X((o), d##_##r##_##f)
1068c2ecf20Sopenharmony_ci#define NVVAL_MW_GET_I(X,o,d,r,f,i) NVVAL_MW_GET_X((o), d##_##r##_##f(i))
1078c2ecf20Sopenharmony_ci#define NVVAL_MW_GET_(X,_1,_2,_3,_4,_5,IMPL,...) IMPL
1088c2ecf20Sopenharmony_ci#define NVVAL_MW_GET(A...) NVVAL_MW_GET_(X, ##A, NVVAL_MW_GET_I, NVVAL_MW_GET_N)(X, ##A)
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#define NVVAL_MW_SET_X(o,drf,v) do {                                           \
1118c2ecf20Sopenharmony_ci	(o)[DRF_LW_IDX((o),drf)] = DRF_LW_SET((o),drf,(v));                    \
1128c2ecf20Sopenharmony_ci	if (DRF_MW_SPANS((o),drf))                                             \
1138c2ecf20Sopenharmony_ci		(o)[DRF_HW_IDX((o),drf)] = DRF_HW_SET((o),drf,(v));            \
1148c2ecf20Sopenharmony_ci} while(0)
1158c2ecf20Sopenharmony_ci#define NVVAL_MW_SET_N(X,o,d,r,f,  v) NVVAL_MW_SET_X((o), d##_##r##_##f, (v))
1168c2ecf20Sopenharmony_ci#define NVVAL_MW_SET_I(X,o,d,r,f,i,v) NVVAL_MW_SET_X((o), d##_##r##_##f(i), (v))
1178c2ecf20Sopenharmony_ci#define NVVAL_MW_SET_(X,_1,_2,_3,_4,_5,_6,IMPL,...) IMPL
1188c2ecf20Sopenharmony_ci#define NVVAL_MW_SET(A...) NVVAL_MW_SET_(X, ##A, NVVAL_MW_SET_I, NVVAL_MW_SET_N)(X, ##A)
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#define NVDEF_MW_SET_N(X,o,d,r,f,  v) NVVAL_MW_SET_X(o, d##_##r##_##f,    d##_##r##_##f##_##v)
1218c2ecf20Sopenharmony_ci#define NVDEF_MW_SET_I(X,o,d,r,f,i,v) NVVAL_MW_SET_X(o, d##_##r##_##f(i), d##_##r##_##f##_##v)
1228c2ecf20Sopenharmony_ci#define NVDEF_MW_SET_(X,_1,_2,_3,_4,_5,_6,IMPL,...) IMPL
1238c2ecf20Sopenharmony_ci#define NVDEF_MW_SET(A...) NVDEF_MW_SET_(X, ##A, NVDEF_MW_SET_I, NVDEF_MW_SET_N)(X, ##A)
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci/* Helper for reading an arbitrary object. */
1268c2ecf20Sopenharmony_ci#define DRF_RD_X(e,p,o,dr) e((p), (o), dr)
1278c2ecf20Sopenharmony_ci#define DRF_RD_N(X,e,p,o,d,r  ) DRF_RD_X(e, (p), (o), d##_##r)
1288c2ecf20Sopenharmony_ci#define DRF_RD_I(X,e,p,o,d,r,i) DRF_RD_X(e, (p), (o), d##_##r(i))
1298c2ecf20Sopenharmony_ci#define DRF_RD_(X,_1,_2,_3,_4,_5,_6,IMPL,...) IMPL
1308c2ecf20Sopenharmony_ci#define DRF_RD(A...) DRF_RD_(X, ##A, DRF_RD_I, DRF_RD_N)(X, ##A)
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci/* Helper for writing an arbitrary object. */
1338c2ecf20Sopenharmony_ci#define DRF_WR_X(e,p,o,dr,v) e((p), (o), dr, (v))
1348c2ecf20Sopenharmony_ci#define DRF_WR_N(X,e,p,o,d,r,  v) DRF_WR_X(e, (p), (o), d##_##r   , (v))
1358c2ecf20Sopenharmony_ci#define DRF_WR_I(X,e,p,o,d,r,i,v) DRF_WR_X(e, (p), (o), d##_##r(i), (v))
1368c2ecf20Sopenharmony_ci#define DRF_WR_(X,_1,_2,_3,_4,_5,_6,_7,IMPL,...) IMPL
1378c2ecf20Sopenharmony_ci#define DRF_WR(A...) DRF_WR_(X, ##A, DRF_WR_I, DRF_WR_N)(X, ##A)
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci/* Helper for modifying an arbitrary object. */
1408c2ecf20Sopenharmony_ci#define DRF_MR_X(er,ew,ty,p,o,dr,m,v) ({               \
1418c2ecf20Sopenharmony_ci	ty _t = DRF_RD_X(er, (p), (o), dr);            \
1428c2ecf20Sopenharmony_ci	DRF_WR_X(ew, (p), (o), dr, (_t & ~(m)) | (v)); \
1438c2ecf20Sopenharmony_ci	_t;                                            \
1448c2ecf20Sopenharmony_ci})
1458c2ecf20Sopenharmony_ci#define DRF_MR_N(X,er,ew,ty,p,o,d,r  ,m,v) DRF_MR_X(er, ew, ty, (p), (o), d##_##r   , (m), (v))
1468c2ecf20Sopenharmony_ci#define DRF_MR_I(X,er,ew,ty,p,o,d,r,i,m,v) DRF_MR_X(er, ew, ty, (p), (o), d##_##r(i), (m), (v))
1478c2ecf20Sopenharmony_ci#define DRF_MR_(X,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,IMPL,...) IMPL
1488c2ecf20Sopenharmony_ci#define DRF_MR(A...) DRF_MR_(X, ##A, DRF_MR_I, DRF_MR_N)(X, ##A)
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci/* Helper for extracting a field value from arbitrary object. */
1518c2ecf20Sopenharmony_ci#define DRF_RV_X(e,p,o,dr,drf) NVVAL_GET_X(DRF_RD_X(e, (p), (o), dr), drf)
1528c2ecf20Sopenharmony_ci#define DRF_RV_N(X,e,p,o,d,r,  f) DRF_RV_X(e, (p), (o), d##_##r   , d##_##r##_##f)
1538c2ecf20Sopenharmony_ci#define DRF_RV_I(X,e,p,o,d,r,i,f) DRF_RV_X(e, (p), (o), d##_##r(i), d##_##r##_##f)
1548c2ecf20Sopenharmony_ci#define DRF_RV_(X,_1,_2,_3,_4,_5,_6,_7,IMPL,...) IMPL
1558c2ecf20Sopenharmony_ci#define DRF_RV(A...) DRF_RV_(X, ##A, DRF_RV_I, DRF_RV_N)(X, ##A)
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci/* Helper for writing field value to arbitrary object (all other bits cleared). */
1588c2ecf20Sopenharmony_ci#define DRF_WV_N(X,e,p,o,d,r,  f,v)                                    \
1598c2ecf20Sopenharmony_ci	DRF_WR_X(e, (p), (o), d##_##r   , NVVAL_X(d##_##r##_##f, (v)))
1608c2ecf20Sopenharmony_ci#define DRF_WV_I(X,e,p,o,d,r,i,f,v)                                    \
1618c2ecf20Sopenharmony_ci	DRF_WR_X(e, (p), (o), d##_##r(i), NVVAL_X(d##_##r##_##f, (v)))
1628c2ecf20Sopenharmony_ci#define DRF_WV_(X,_1,_2,_3,_4,_5,_6,_7,_8,IMPL,...) IMPL
1638c2ecf20Sopenharmony_ci#define DRF_WV(A...) DRF_WV_(X, ##A, DRF_WV_I, DRF_WV_N)(X, ##A)
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci/* Helper for writing field definition to arbitrary object (all other bits cleared). */
1668c2ecf20Sopenharmony_ci#define DRF_WD_N(X,e,p,o,d,r,  f,v)                                                    \
1678c2ecf20Sopenharmony_ci	DRF_WR_X(e, (p), (o), d##_##r   , NVVAL_X(d##_##r##_##f, d##_##r##_##f##_##v))
1688c2ecf20Sopenharmony_ci#define DRF_WD_I(X,e,p,o,d,r,i,f,v)                                                    \
1698c2ecf20Sopenharmony_ci	DRF_WR_X(e, (p), (o), d##_##r(i), NVVAL_X(d##_##r##_##f, d##_##r##_##f##_##v))
1708c2ecf20Sopenharmony_ci#define DRF_WD_(X,_1,_2,_3,_4,_5,_6,_7,_8,IMPL,...) IMPL
1718c2ecf20Sopenharmony_ci#define DRF_WD(A...) DRF_WD_(X, ##A, DRF_WD_I, DRF_WD_N)(X, ##A)
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci/* Helper for modifying field value in arbitrary object. */
1748c2ecf20Sopenharmony_ci#define DRF_MV_N(X,er,ew,ty,p,o,d,r,  f,v)                                               \
1758c2ecf20Sopenharmony_ci	NVVAL_GET_X(DRF_MR_X(er, ew, ty, (p), (o), d##_##r   , DRF_SMASK(d##_##r##_##f), \
1768c2ecf20Sopenharmony_ci		    NVVAL_X(d##_##r##_##f, (v))), d##_##r##_##f)
1778c2ecf20Sopenharmony_ci#define DRF_MV_I(X,er,ew,ty,p,o,d,r,i,f,v)                                               \
1788c2ecf20Sopenharmony_ci	NVVAL_GET_X(DRF_MR_X(er, ew, ty, (p), (o), d##_##r(i), DRF_SMASK(d##_##r##_##f), \
1798c2ecf20Sopenharmony_ci		    NVVAL_X(d##_##r##_##f, (v))), d##_##r##_##f)
1808c2ecf20Sopenharmony_ci#define DRF_MV_(X,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,IMPL,...) IMPL
1818c2ecf20Sopenharmony_ci#define DRF_MV(A...) DRF_MV_(X, ##A, DRF_MV_I, DRF_MV_N)(X, ##A)
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci/* Helper for modifying field definition in arbitrary object. */
1848c2ecf20Sopenharmony_ci#define DRF_MD_N(X,er,ew,ty,p,o,d,r,  f,v)                                               \
1858c2ecf20Sopenharmony_ci	NVVAL_GET_X(DRF_MR_X(er, ew, ty, (p), (o), d##_##r   , DRF_SMASK(d##_##r##_##f), \
1868c2ecf20Sopenharmony_ci		    NVVAL_X(d##_##r##_##f, d##_##r##_##f##_##v)), d##_##r##_##f)
1878c2ecf20Sopenharmony_ci#define DRF_MD_I(X,er,ew,ty,p,o,d,r,i,f,v)                                               \
1888c2ecf20Sopenharmony_ci	NVVAL_GET_X(DRF_MR_X(er, ew, ty, (p), (o), d##_##r(i), DRF_SMASK(d##_##r##_##f), \
1898c2ecf20Sopenharmony_ci		    NVVAL_X(d##_##r##_##f, d##_##r##_##f##_##v)), d##_##r##_##f)
1908c2ecf20Sopenharmony_ci#define DRF_MD_(X,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,IMPL,...) IMPL
1918c2ecf20Sopenharmony_ci#define DRF_MD(A...) DRF_MD_(X, ##A, DRF_MD_I, DRF_MD_N)(X, ##A)
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci/* Helper for testing against field value in aribtrary object */
1948c2ecf20Sopenharmony_ci#define DRF_TV_N(X,e,p,o,d,r,  f,cmp,v)                                          \
1958c2ecf20Sopenharmony_ci	NVVAL_TEST_X(DRF_RD_X(e, (p), (o), d##_##r   ), d##_##r##_##f, cmp, (v))
1968c2ecf20Sopenharmony_ci#define DRF_TV_I(X,e,p,o,d,r,i,f,cmp,v)                                          \
1978c2ecf20Sopenharmony_ci	NVVAL_TEST_X(DRF_RD_X(e, (p), (o), d##_##r(i)), d##_##r##_##f, cmp, (v))
1988c2ecf20Sopenharmony_ci#define DRF_TV_(X,_1,_2,_3,_4,_5,_6,_7,_8,_9,IMPL,...) IMPL
1998c2ecf20Sopenharmony_ci#define DRF_TV(A...) DRF_TV_(X, ##A, DRF_TV_I, DRF_TV_N)(X, ##A)
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci/* Helper for testing against field definition in aribtrary object */
2028c2ecf20Sopenharmony_ci#define DRF_TD_N(X,e,p,o,d,r,  f,cmp,v)                                                          \
2038c2ecf20Sopenharmony_ci	NVVAL_TEST_X(DRF_RD_X(e, (p), (o), d##_##r   ), d##_##r##_##f, cmp, d##_##r##_##f##_##v)
2048c2ecf20Sopenharmony_ci#define DRF_TD_I(X,e,p,o,d,r,i,f,cmp,v)                                                          \
2058c2ecf20Sopenharmony_ci	NVVAL_TEST_X(DRF_RD_X(e, (p), (o), d##_##r(i)), d##_##r##_##f, cmp, d##_##r##_##f##_##v)
2068c2ecf20Sopenharmony_ci#define DRF_TD_(X,_1,_2,_3,_4,_5,_6,_7,_8,_9,IMPL,...) IMPL
2078c2ecf20Sopenharmony_ci#define DRF_TD(A...) DRF_TD_(X, ##A, DRF_TD_I, DRF_TD_N)(X, ##A)
2088c2ecf20Sopenharmony_ci#endif
209