Permalink
Browse files

start hooking up rnndec to decode registers and bitfields

So cffdump script can do things like r.SP_VS_OUT[0].A_COMPMASK to get
decoded bitfield values.
  • Loading branch information...
robclark committed Oct 7, 2014
1 parent 64f835c commit 45aabc195e889bba90a905dbbbd5a7e999dfd363
Showing with 344 additions and 12 deletions.
  1. +6 −0 scripts/test.lua
  2. +51 −6 util/rnnutil.c
  3. +11 −0 util/rnnutil.h
  4. +276 −6 util/script.c
View
@@ -1,11 +1,17 @@
io.write("HELLO WORLD\n")
+r = rnn.init("a320")
+
function start_cmdstream(name)
io.write("START: " .. name .. "\n")
end
function draw(primtype, nindx)
io.write("DRAW: " .. primtype .. ", " .. nindx .. "\n")
+ io.write("GRAS_CL_VPORT_XOFFSET: " .. r.GRAS_CL_VPORT_XOFFSET .. "\n")
+ io.write("RB_MRT[0].CONTROL.ROP_CODE: " .. r.RB_MRT[0].CONTROL.ROP_CODE .. "\n")
+ io.write("SP_VS_OUT[0].A_COMPMASK: " .. r.SP_VS_OUT[0].A_COMPMASK .. "\n")
+ io.write("RB_DEPTH_CONTROL.Z_ENABLE: " .. tostring(r.RB_DEPTH_CONTROL.Z_ENABLE) .. "\n")
io.write("0x2280: written=" .. regs.written(0x2280) .. ", lastval=" .. regs.lastval(0x2280) .. ", val=" .. regs.val(0x2280) .. "\n")
end
View
@@ -41,13 +41,8 @@ static struct rnndomain *finddom(struct rnn *rnn, uint32_t regbase)
return rnn->dom[1];
}
-struct rnn *rnn_new(int nocolor)
+void _rnn_init(struct rnn *rnn, int nocolor)
{
- struct rnn *rnn = calloc(sizeof(*rnn), 1);
-
- if (!rnn)
- return NULL;
-
rnn_init();
rnn->db = rnn_newdb();
@@ -59,6 +54,16 @@ struct rnn *rnn_new(int nocolor)
rnn->vc = rnndec_newcontext(rnn->db);
rnn->vc->colors = &envy_def_colors;
}
+}
+
+struct rnn *rnn_new(int nocolor)
+{
+ struct rnn *rnn = calloc(sizeof(*rnn), 1);
+
+ if (!rnn)
+ return NULL;
+
+ _rnn_init(rnn, nocolor);
return rnn;
}
@@ -116,3 +121,43 @@ const char *rnn_enumname(struct rnn *rnn, const char *name, uint32_t val)
{
return rnndec_decode_enum(rnn->vc, name, val);
}
+
+static struct rnndelem *regelem(struct rnndomain *domain, const char *name)
+{
+ int i;
+ for (i = 0; i < domain->subelemsnum; i++) {
+ struct rnndelem *elem = domain->subelems[i];
+ if (!strcmp(elem->name, name))
+ return elem;
+ }
+ return NULL;
+}
+
+struct rnndelem *rnn_regelem(struct rnn *rnn, const char *name)
+{
+ struct rnndelem *elem = regelem(rnn->dom[0], name);
+ if (elem)
+ return elem;
+ return regelem(rnn->dom[1], name);
+}
+
+enum rnnttype rnn_decodelem(struct rnn *rnn, struct rnntypeinfo *info,
+ uint32_t regval, union rnndecval *val)
+{
+ val->u = regval;
+ switch (info->type) {
+ case RNN_TTYPE_INLINE_ENUM:
+ case RNN_TTYPE_ENUM:
+ case RNN_TTYPE_HEX:
+ case RNN_TTYPE_INT:
+ case RNN_TTYPE_UINT:
+ case RNN_TTYPE_FLOAT:
+ case RNN_TTYPE_BOOLEAN:
+ return info->type;
+ case RNN_TTYPE_FIXED:
+ case RNN_TTYPE_UFIXED:
+ /* TODO */
+ default:
+ return RNN_TTYPE_INVALID;
+ }
+}
View
@@ -42,10 +42,21 @@ struct rnn {
struct rnndomain *dom[2];
};
+union rnndecval {
+ uint32_t u;
+ int32_t i;
+ float f;
+};
+
+void _rnn_init(struct rnn *rnn, int nocolor);
struct rnn *rnn_new(int nocolor);
void rnn_load(struct rnn *rnn, const char *gpuname);
const char *rnn_regname(struct rnn *rnn, uint32_t regbase, int color);
struct rnndecaddrinfo *rnn_reginfo(struct rnn *rnn, uint32_t regbase);
const char *rnn_enumname(struct rnn *rnn, const char *name, uint32_t val);
+struct rnndelem *rnn_regelem(struct rnn *rnn, const char *name);
+enum rnnttype rnn_decodelem(struct rnn *rnn, struct rnntypeinfo *info,
+ uint32_t regval, union rnndecval *val);
+
#endif /* RNNUTIL_H_ */
Oops, something went wrong.

0 comments on commit 45aabc1

Please sign in to comment.